mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-22 16:10:36 +02:00
Merge commit 'origin/master' into glsl-pp-rework-2
Conflicts: src/gallium/winsys/gdi/SConscript
This commit is contained in:
commit
2a661c383f
144 changed files with 5850 additions and 3000 deletions
|
|
@ -23,6 +23,7 @@ HOST_CC = $(CC)
|
|||
CFLAGS = -O
|
||||
CXXFLAGS = -O
|
||||
LDFLAGS =
|
||||
HOST_CFLAGS = $(CFLAGS)
|
||||
GLU_CFLAGS =
|
||||
|
||||
# Compiler for building demos/tests/etc
|
||||
|
|
|
|||
|
|
@ -1202,7 +1202,7 @@ if test "x$enable_gallium_radeon" = xyes; then
|
|||
fi
|
||||
|
||||
dnl
|
||||
dnl Gallium Radeon configuration
|
||||
dnl Gallium Nouveau configuration
|
||||
dnl
|
||||
AC_ARG_ENABLE([gallium-nouveau],
|
||||
[AS_HELP_STRING([--enable-gallium-nouveau],
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ tbd
|
|||
<ul>
|
||||
<li>Assorted bug fixes for i965/i945 drivers
|
||||
<li>Fixed Gallium glDrawPixels(GL_STENCIL_INDEX) failure.
|
||||
<li>Fixed GLSL linker/preprocessor version directive issue seen in Wine
|
||||
(such as bug 23946)
|
||||
<li>glUseProgram() is now compiled into display lists (bug 23746).
|
||||
<li>glUniform functions are now compiled into display lists
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ This was written by Zack Rusin at Tungsten Graphics.
|
|||
GL_ARB_fragment_program.</li>
|
||||
<li>Added configure --with-max-width=W, --with-max-height=H options to specify
|
||||
max framebuffer, viewport size.
|
||||
<li>Initial version of Gallium llvmpipe driver. This is a new driver based
|
||||
on LLVM which makes exensive use of run-time code generation. This is
|
||||
an "alpha" stage driver. See the src/gallium/drivers/llvmpipe/README
|
||||
file for more information.
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ tbd
|
|||
<li>GL_ARB_draw_elements_base_vertex (supported in Intel i965 and software drivers)</li>
|
||||
<li>GL_ARB_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
|
||||
<li>GL_NV_depth_clamp (supported in Intel i965 DRI and software drivers)</li>
|
||||
<li>GL_ARB_provoking_vertex (same as GL_EXT_provoking_vertex)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1740,6 +1740,9 @@ GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
|
|||
GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
|
||||
GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
|
||||
|
||||
typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -1945,6 +1948,18 @@ GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
|
|||
GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
|
||||
|
||||
|
||||
typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
|
||||
typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
|
||||
typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ static GLint ClampIndex = 0;
|
|||
static GLboolean supportFBO = GL_FALSE;
|
||||
static GLboolean supportSeamless = GL_FALSE;
|
||||
static GLboolean seamless = GL_FALSE;
|
||||
static GLuint TexObj = 0;
|
||||
|
||||
|
||||
static struct {
|
||||
|
|
@ -543,6 +544,10 @@ static void init( GLboolean useImageFiles )
|
|||
|
||||
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
|
||||
glGenTextures(1, &TexObj);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, TexObj);
|
||||
|
||||
if (useImageFiles) {
|
||||
load_envmaps();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ static GLboolean Anim = GL_TRUE;
|
|||
static GLint Bias = 0, BiasStepSign = +1; /* ints avoid fp precision problem */
|
||||
static GLint BiasMin = -400, BiasMax = 400;
|
||||
static int win = 0;
|
||||
static GLuint TexObj = 0;
|
||||
|
||||
|
||||
static void
|
||||
|
|
@ -214,6 +215,9 @@ static void Init( void )
|
|||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glGenTextures(1, &TexObj);
|
||||
glBindTexture(GL_TEXTURE_2D, TexObj);
|
||||
|
||||
if (glutExtensionSupported("GL_SGIS_generate_mipmap")) {
|
||||
/* test auto mipmap generation */
|
||||
GLint width, height, i;
|
||||
|
|
|
|||
|
|
@ -10,16 +10,15 @@ LIB_DEP = \
|
|||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/progs/util
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) \
|
||||
-l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
|
||||
# using : to avoid APP_CC pointing to CC loop
|
||||
CC:=$(APP_CC)
|
||||
CC := $(APP_CC)
|
||||
CFLAGS += -I$(INCDIR)
|
||||
LDLIBS=$(LIBS)
|
||||
LDLIBS = $(LIBS)
|
||||
|
||||
DEMO_SOURCES = \
|
||||
PROG_SOURCES = \
|
||||
array.c \
|
||||
bitmap.c \
|
||||
brick.c \
|
||||
|
|
@ -59,8 +58,8 @@ UTIL_SOURCES = \
|
|||
readtex.c
|
||||
|
||||
UTIL_OBJS = $(UTIL_SOURCES:.c=.o)
|
||||
PROG_OBJS = $(DEMO_SOURCES:.c=.o)
|
||||
PROGS = $(DEMO_SOURCES:%.c=%)
|
||||
PROG_OBJS = $(PROG_SOURCES:.c=.o)
|
||||
PROGS = $(PROG_SOURCES:%.c=%)
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
|
|
|
|||
49
progs/perf/Makefile
Normal file
49
progs/perf/Makefile
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# progs/demos/Makefile
|
||||
|
||||
TOP = ../..
|
||||
include $(TOP)/configs/current
|
||||
|
||||
INCDIR = $(TOP)/include
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) \
|
||||
-l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
|
||||
# using : to avoid APP_CC pointing to CC loop
|
||||
CC := $(APP_CC)
|
||||
CFLAGS += -I$(INCDIR)
|
||||
LDLIBS = $(LIBS)
|
||||
|
||||
PROG_SOURCES = \
|
||||
drawoverhead.c \
|
||||
teximage.c \
|
||||
vbo.c \
|
||||
vertexrate.c \
|
||||
|
||||
PROG_OBJS = $(PROG_SOURCES:.c=.o)
|
||||
|
||||
PROGS = $(PROG_SOURCES:%.c=%)
|
||||
|
||||
|
||||
UTIL_SOURCES = \
|
||||
common.c \
|
||||
glmain.c
|
||||
|
||||
UTIL_HEADERS = \
|
||||
common.h \
|
||||
glmain.h
|
||||
|
||||
UTIL_OBJS = $(UTIL_SOURCES:.c=.o)
|
||||
|
||||
|
||||
|
||||
default: $(PROGS)
|
||||
|
||||
$(PROG_OBJS): $(UTIL_HEADERS)
|
||||
|
||||
$(PROGS): $(UTIL_OBJS)
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
-rm -f $(PROGS)
|
||||
-rm -f *.o *~
|
||||
93
progs/perf/common.c
Normal file
93
progs/perf/common.c
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common perf code. This should be re-usable with other APIs.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "glmain.h"
|
||||
|
||||
|
||||
/**
|
||||
* Run function 'f' for enough iterations to reach a steady state.
|
||||
* Return the rate (iterations/second).
|
||||
*/
|
||||
double
|
||||
PerfMeasureRate(PerfRateFunc f)
|
||||
{
|
||||
const double minDuration = 1.0;
|
||||
double rate = 0.0, prevRate = 0.0;
|
||||
unsigned subiters;
|
||||
|
||||
/* Compute initial number of iterations to try.
|
||||
* If the test function is pretty slow this helps to avoid
|
||||
* extraordarily long run times.
|
||||
*/
|
||||
subiters = 2;
|
||||
{
|
||||
const double t0 = PerfGetTime();
|
||||
double t1;
|
||||
do {
|
||||
f(subiters); /* call the rendering function */
|
||||
t1 = PerfGetTime();
|
||||
subiters *= 2;
|
||||
} while (t1 - t0 < 0.1 * minDuration);
|
||||
}
|
||||
/*printf("initial subIters = %u\n", subiters);*/
|
||||
|
||||
while (1) {
|
||||
const double t0 = PerfGetTime();
|
||||
unsigned iters = 0;
|
||||
double t1;
|
||||
|
||||
do {
|
||||
f(subiters); /* call the rendering function */
|
||||
t1 = PerfGetTime();
|
||||
iters += subiters;
|
||||
} while (t1 - t0 < minDuration);
|
||||
|
||||
rate = iters / (t1 - t0);
|
||||
|
||||
if (0)
|
||||
printf("prevRate %f rate %f ratio %f iters %u\n",
|
||||
prevRate, rate, rate/prevRate, iters);
|
||||
|
||||
/* Try and speed the search up by skipping a few steps:
|
||||
*/
|
||||
if (rate > prevRate * 1.6)
|
||||
subiters *= 8;
|
||||
else if (rate > prevRate * 1.2)
|
||||
subiters *= 4;
|
||||
else if (rate > prevRate * 1.05)
|
||||
subiters *= 2;
|
||||
else
|
||||
break;
|
||||
|
||||
prevRate = rate;
|
||||
}
|
||||
|
||||
if (0)
|
||||
printf("%s returning iters %u rate %f\n", __FUNCTION__, subiters, rate);
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
35
progs/perf/common.h
Normal file
35
progs/perf/common.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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 COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
|
||||
typedef void (*PerfRateFunc)(unsigned count);
|
||||
|
||||
|
||||
extern double
|
||||
PerfMeasureRate(PerfRateFunc f);
|
||||
|
||||
|
||||
#endif /* COMMON_H */
|
||||
|
||||
133
progs/perf/drawoverhead.c
Normal file
133
progs/perf/drawoverhead.c
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Measure drawing overhead
|
||||
*
|
||||
* This is the first in a series of simple performance benchmarks.
|
||||
* The code in this file should be as simple as possible to make it
|
||||
* easily portable to other APIs.
|
||||
*
|
||||
* All the window-system stuff should be contained in glmain.c (or TBDmain.c).
|
||||
* All the re-usable, generic code should be in common.c (XXX not done yet).
|
||||
*
|
||||
* Brian Paul
|
||||
* 15 Sep 2009
|
||||
*/
|
||||
|
||||
#include "glmain.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
int WinWidth = 100, WinHeight = 100;
|
||||
|
||||
static GLuint VBO;
|
||||
|
||||
struct vertex
|
||||
{
|
||||
GLfloat x, y;
|
||||
};
|
||||
|
||||
static const struct vertex vertices[4] = {
|
||||
{ -1.0, -1.0 },
|
||||
{ 1.0, -1.0 },
|
||||
{ 1.0, 1.0 },
|
||||
{ -1.0, 1.0 }
|
||||
};
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfInit(void)
|
||||
{
|
||||
/* setup VBO w/ vertex data */
|
||||
glGenBuffersARB(1, &VBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
|
||||
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), (void *) 0);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
/* misc GL state */
|
||||
glAlphaFunc(GL_ALWAYS, 0.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawNoStateChange(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawArrays(GL_POINTS, 0, 4);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawNopStateChange(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDrawArrays(GL_POINTS, 0, 4);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawStateChange(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (i & 1)
|
||||
glEnable(GL_TEXTURE_GEN_S);
|
||||
else
|
||||
glDisable(GL_TEXTURE_GEN_S);
|
||||
glDrawArrays(GL_POINTS, 0, 4);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfDraw(void)
|
||||
{
|
||||
double rate0, rate1, rate2, overhead;
|
||||
|
||||
rate0 = PerfMeasureRate(DrawNoStateChange);
|
||||
printf(" Draw only: %.1f draws/second\n", rate0);
|
||||
|
||||
rate1 = PerfMeasureRate(DrawNopStateChange);
|
||||
overhead = 1000.0 * (1.0 / rate1 - 1.0 / rate0);
|
||||
printf(" Draw w/ nop state change: %.1f draws/sec (overhead: %f ms/draw)\n",
|
||||
rate1, overhead);
|
||||
|
||||
rate2 = PerfMeasureRate(DrawStateChange);
|
||||
overhead = 1000.0 * (1.0 / rate2 - 1.0 / rate0);
|
||||
printf(" Draw w/ state change: %.1f draws/sec (overhead: %f ms/draw)\n",
|
||||
rate2, overhead);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
156
progs/perf/glmain.c
Normal file
156
progs/perf/glmain.c
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* OpenGL/GLUT common code for perf programs.
|
||||
* Brian Paul
|
||||
* 15 Sep 2009
|
||||
*/
|
||||
|
||||
|
||||
#include "glmain.h"
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static int Win;
|
||||
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
|
||||
|
||||
/** Return time in seconds */
|
||||
double
|
||||
PerfGetTime(void)
|
||||
{
|
||||
return glutGet(GLUT_ELAPSED_TIME) * 0.001;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PerfSwapBuffers(void)
|
||||
{
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
Xrot += 3.0;
|
||||
Yrot += 4.0;
|
||||
Zrot += 2.0;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Draw(void)
|
||||
{
|
||||
PerfDraw();
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
WinWidth = width;
|
||||
WinHeight = height;
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 3.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 'z':
|
||||
Zrot -= step;
|
||||
break;
|
||||
case 'Z':
|
||||
Zrot += step;
|
||||
break;
|
||||
case 27:
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 3.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case GLUT_KEY_UP:
|
||||
Xrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
Xrot += step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
Yrot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
Yrot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Draw);
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
PerfInit();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
54
progs/perf/glmain.h
Normal file
54
progs/perf/glmain.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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 GLMAIN_H
|
||||
#define GLMAIN_H
|
||||
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GL/glew.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/** Test programs can use these vars/functions */
|
||||
|
||||
extern int WinWidth, WinHeight;
|
||||
|
||||
extern double
|
||||
PerfGetTime(void);
|
||||
|
||||
extern void
|
||||
PerfSwapBuffers(void);
|
||||
|
||||
|
||||
/** Test programs must implement these functions **/
|
||||
|
||||
extern void
|
||||
PerfInit(void);
|
||||
|
||||
extern void
|
||||
PerfDraw(void);
|
||||
|
||||
|
||||
#endif /* GLMAIN_H */
|
||||
210
progs/perf/teximage.c
Normal file
210
progs/perf/teximage.c
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Measure glTexSubImage2D rate
|
||||
*
|
||||
* Brian Paul
|
||||
* 16 Sep 2009
|
||||
*/
|
||||
|
||||
#include "glmain.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
int WinWidth = 100, WinHeight = 100;
|
||||
|
||||
static GLuint VBO;
|
||||
static GLuint TexObj = 0;
|
||||
static GLubyte *TexImage = NULL;
|
||||
static GLsizei TexSize;
|
||||
static GLenum TexSrcFormat, TexSrcType;
|
||||
|
||||
static const GLboolean DrawPoint = GL_TRUE;
|
||||
static const GLboolean TexSubImage4 = GL_TRUE;
|
||||
|
||||
struct vertex
|
||||
{
|
||||
GLfloat x, y, s, t;
|
||||
};
|
||||
|
||||
static const struct vertex vertices[1] = {
|
||||
{ 0.0, 0.0, 0.5, 0.5 },
|
||||
};
|
||||
|
||||
|
||||
#define VOFFSET(F) ((void *) offsetof(struct vertex, F))
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfInit(void)
|
||||
{
|
||||
/* setup VBO w/ vertex data */
|
||||
glGenBuffersARB(1, &VBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
|
||||
sizeof(vertices), vertices, GL_STATIC_DRAW_ARB);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(x));
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), VOFFSET(s));
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
/* texture */
|
||||
glGenTextures(1, &TexObj);
|
||||
glBindTexture(GL_TEXTURE_2D, TexObj);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
UploadTexImage2D(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
/* XXX is this equivalent to a glTexSubImage call since we're
|
||||
* always specifying the same image size? That case isn't optimized
|
||||
* in Mesa but may be optimized in other drivers. Note sure how
|
||||
* much difference that might make.
|
||||
*/
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
TexSize, TexSize, 0,
|
||||
TexSrcFormat, TexSrcType, TexImage);
|
||||
if (DrawPoint)
|
||||
glDrawArrays(GL_POINTS, 0, 1);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
UploadTexSubImage2D(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (TexSubImage4) {
|
||||
GLsizei halfSize = (TexSize == 1) ? 1 : TexSize / 2;
|
||||
GLsizei halfPos = TexSize - halfSize;
|
||||
/* do glTexSubImage2D in four pieces */
|
||||
/* lower-left */
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, TexSize);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
0, 0, halfSize, halfSize,
|
||||
TexSrcFormat, TexSrcType, TexImage);
|
||||
/* lower-right */
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, halfPos);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
halfPos, 0, halfSize, halfSize,
|
||||
TexSrcFormat, TexSrcType, TexImage);
|
||||
/* upper-left */
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, halfPos);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
0, halfPos, halfSize, halfSize,
|
||||
TexSrcFormat, TexSrcType, TexImage);
|
||||
/* upper-right */
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, halfPos);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, halfPos);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
halfPos, halfPos, halfSize, halfSize,
|
||||
TexSrcFormat, TexSrcType, TexImage);
|
||||
/* reset the unpacking state */
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
|
||||
}
|
||||
else {
|
||||
/* replace whole texture image at once */
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
0, 0, TexSize, TexSize,
|
||||
TexSrcFormat, TexSrcType, TexImage);
|
||||
}
|
||||
if (DrawPoint)
|
||||
glDrawArrays(GL_POINTS, 0, 1);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
/* XXX any other formats to measure? */
|
||||
static const struct {
|
||||
GLenum format, type;
|
||||
const char *name;
|
||||
} SrcFormats[] = {
|
||||
{ GL_RGBA, GL_UNSIGNED_BYTE, "GL_RGBA/GLubyte" },
|
||||
{ GL_BGRA, GL_UNSIGNED_BYTE, "GL_BGRA/GLubyte" },
|
||||
{ 0, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfDraw(void)
|
||||
{
|
||||
GLint maxSize;
|
||||
double rate;
|
||||
GLint fmt, subImage;
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
|
||||
|
||||
/* loop over source data formats */
|
||||
for (fmt = 0; SrcFormats[fmt].format; fmt++) {
|
||||
TexSrcFormat = SrcFormats[fmt].format;
|
||||
TexSrcType = SrcFormats[fmt].type;
|
||||
|
||||
/* loop over glTexImage, glTexSubImage */
|
||||
for (subImage = 0; subImage < 2; subImage++) {
|
||||
|
||||
/* loop over texture sizes */
|
||||
for (TexSize = 16; TexSize <= maxSize; TexSize *= 2) {
|
||||
GLint bytesPerImage;
|
||||
double mbPerSec;
|
||||
|
||||
bytesPerImage = TexSize * TexSize * 4;
|
||||
TexImage = malloc(bytesPerImage);
|
||||
|
||||
if (subImage) {
|
||||
/* create initial, empty texture */
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
TexSize, TexSize, 0,
|
||||
TexSrcFormat, TexSrcType, NULL);
|
||||
rate = PerfMeasureRate(UploadTexSubImage2D);
|
||||
}
|
||||
else {
|
||||
rate = PerfMeasureRate(UploadTexImage2D);
|
||||
}
|
||||
|
||||
mbPerSec = rate * bytesPerImage / (1024.0 * 1024.0);
|
||||
|
||||
printf(" glTex%sImage2D(%s %d x %d): "
|
||||
"%.1f images/sec, %.1f MB/sec\n",
|
||||
(subImage ? "Sub" : ""),
|
||||
SrcFormats[fmt].name, TexSize, TexSize, rate, mbPerSec);
|
||||
|
||||
free(TexImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
138
progs/perf/vbo.c
Normal file
138
progs/perf/vbo.c
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Measure VBO upload speed.
|
||||
* That is, measure glBufferDataARB() and glBufferSubDataARB().
|
||||
*
|
||||
* Brian Paul
|
||||
* 16 Sep 2009
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "glmain.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
int WinWidth = 100, WinHeight = 100;
|
||||
|
||||
static GLuint VBO;
|
||||
|
||||
static GLsizei VBOSize = 0;
|
||||
static GLubyte *VBOData = NULL;
|
||||
|
||||
static const GLboolean DrawPoint = GL_TRUE;
|
||||
static const GLboolean BufferSubDataInHalves = GL_TRUE;
|
||||
|
||||
static const GLfloat Vertex0[2] = { 0.0, 0.0 };
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfInit(void)
|
||||
{
|
||||
/* setup VBO */
|
||||
glGenBuffersARB(1, &VBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(Vertex0), (void *) 0);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
UploadVBO(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
glBufferDataARB(GL_ARRAY_BUFFER, VBOSize, VBOData, GL_STREAM_DRAW_ARB);
|
||||
|
||||
if (DrawPoint)
|
||||
glDrawArrays(GL_POINTS, 0, 1);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
UploadSubVBO(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < count; i++) {
|
||||
if (BufferSubDataInHalves) {
|
||||
GLsizei half = VBOSize / 2;
|
||||
glBufferSubDataARB(GL_ARRAY_BUFFER, 0, half, VBOData);
|
||||
glBufferSubDataARB(GL_ARRAY_BUFFER, half, half, VBOData + half);
|
||||
}
|
||||
else {
|
||||
glBufferSubDataARB(GL_ARRAY_BUFFER, 0, VBOSize, VBOData);
|
||||
}
|
||||
|
||||
if (DrawPoint)
|
||||
glDrawArrays(GL_POINTS, 0, 1);
|
||||
}
|
||||
glFinish();
|
||||
}
|
||||
|
||||
|
||||
static const GLsizei Sizes[] = {
|
||||
64,
|
||||
1024,
|
||||
16*1024,
|
||||
256*1024,
|
||||
1024*1024,
|
||||
16*1024*1024,
|
||||
0 /* end of list */
|
||||
};
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfDraw(void)
|
||||
{
|
||||
double rate, mbPerSec;
|
||||
int sub, sz;
|
||||
|
||||
/* loop over whole/sub buffer upload */
|
||||
for (sub = 0; sub < 2; sub++) {
|
||||
|
||||
/* loop over VBO sizes */
|
||||
for (sz = 0; Sizes[sz]; sz++) {
|
||||
VBOSize = Sizes[sz];
|
||||
|
||||
VBOData = malloc(VBOSize);
|
||||
memcpy(VBOData, Vertex0, sizeof(Vertex0));
|
||||
|
||||
if (sub)
|
||||
rate = PerfMeasureRate(UploadSubVBO);
|
||||
else
|
||||
rate = PerfMeasureRate(UploadVBO);
|
||||
|
||||
mbPerSec = rate * VBOSize / (1024.0 * 1024.0);
|
||||
|
||||
printf(" glBuffer%sDataARB(size = %d): %.1f MB/sec\n",
|
||||
(sub ? "Sub" : ""), VBOSize, mbPerSec);
|
||||
|
||||
free(VBOData);
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
271
progs/perf/vertexrate.c
Normal file
271
progs/perf/vertexrate.c
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. 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, sublicense,
|
||||
* 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* VMWARE 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Measure simple vertex processing rate via:
|
||||
* - immediate mode
|
||||
* - vertex arrays
|
||||
* - VBO vertex arrays
|
||||
* - glDrawElements
|
||||
* - VBO glDrawElements
|
||||
* - glDrawRangeElements
|
||||
* - VBO glDrawRangeElements
|
||||
*
|
||||
* Brian Paul
|
||||
* 16 Sep 2009
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "glmain.h"
|
||||
#include "common.h"
|
||||
|
||||
|
||||
#define MAX_VERTS (100 * 100)
|
||||
|
||||
/** glVertex2/3/4 size */
|
||||
#define VERT_SIZE 4
|
||||
|
||||
int WinWidth = 500, WinHeight = 500;
|
||||
|
||||
static GLuint VertexBO, ElementBO;
|
||||
|
||||
static unsigned NumVerts = MAX_VERTS;
|
||||
static unsigned VertBytes = VERT_SIZE * sizeof(float);
|
||||
static float *VertexData = NULL;
|
||||
|
||||
static unsigned NumElements = MAX_VERTS;
|
||||
static GLuint *Elements = NULL;
|
||||
|
||||
|
||||
/**
|
||||
* Load VertexData buffer with a 2-D grid of points in the range [-1,1]^2.
|
||||
*/
|
||||
static void
|
||||
InitializeVertexData(void)
|
||||
{
|
||||
unsigned i;
|
||||
float x = -1.0, y = -1.0;
|
||||
float dx = 2.0 / 100;
|
||||
float dy = 2.0 / 100;
|
||||
|
||||
VertexData = (float *) malloc(NumVerts * VertBytes);
|
||||
|
||||
for (i = 0; i < NumVerts; i++) {
|
||||
VertexData[i * VERT_SIZE + 0] = x;
|
||||
VertexData[i * VERT_SIZE + 1] = y;
|
||||
VertexData[i * VERT_SIZE + 2] = 0.0;
|
||||
VertexData[i * VERT_SIZE + 3] = 1.0;
|
||||
x += dx;
|
||||
if (x > 1.0) {
|
||||
x = -1.0;
|
||||
y += dy;
|
||||
}
|
||||
}
|
||||
|
||||
Elements = (GLuint *) malloc(NumVerts * sizeof(GLuint));
|
||||
|
||||
for (i = 0; i < NumVerts; i++) {
|
||||
Elements[i] = NumVerts - i - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfInit(void)
|
||||
{
|
||||
InitializeVertexData();
|
||||
|
||||
/* setup VertexBO */
|
||||
glGenBuffersARB(1, &VertexBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VertexBO);
|
||||
glBufferDataARB(GL_ARRAY_BUFFER_ARB,
|
||||
NumVerts * VertBytes, VertexData, GL_STATIC_DRAW_ARB);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
/* setup ElementBO */
|
||||
glGenBuffersARB(1, &ElementBO);
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ElementBO);
|
||||
glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,
|
||||
NumElements * sizeof(GLuint), Elements, GL_STATIC_DRAW_ARB);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawImmediate(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||
for (i = 0; i < count; i++) {
|
||||
unsigned j;
|
||||
glBegin(GL_POINTS);
|
||||
for (j = 0; j < NumVerts; j++) {
|
||||
#if VERT_SIZE == 4
|
||||
glVertex4fv(VertexData + j * 4);
|
||||
#elif VERT_SIZE == 3
|
||||
glVertex3fv(VertexData + j * 3);
|
||||
#elif VERT_SIZE == 2
|
||||
glVertex2fv(VertexData + j * 2);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawArraysMem(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, VertexData);
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawArrays(GL_POINTS, 0, NumVerts);
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawArraysVBO(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, VertexBO);
|
||||
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, (void *) 0);
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawArrays(GL_POINTS, 0, NumVerts);
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawElementsMem(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, VertexData);
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawElements(GL_POINTS, NumVerts, GL_UNSIGNED_INT, Elements);
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawElementsBO(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, ElementBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, VertexBO);
|
||||
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, (void *) 0);
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawElements(GL_POINTS, NumVerts, GL_UNSIGNED_INT, (void *) 0);
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawRangeElementsMem(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, 0);
|
||||
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, VertexData);
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawRangeElements(GL_POINTS, 0, NumVerts - 1,
|
||||
NumVerts, GL_UNSIGNED_INT, Elements);
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
DrawRangeElementsBO(unsigned count)
|
||||
{
|
||||
unsigned i;
|
||||
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, ElementBO);
|
||||
glBindBufferARB(GL_ARRAY_BUFFER, VertexBO);
|
||||
glVertexPointer(VERT_SIZE, GL_FLOAT, VertBytes, (void *) 0);
|
||||
for (i = 0; i < count; i++) {
|
||||
glDrawRangeElements(GL_POINTS, 0, NumVerts - 1,
|
||||
NumVerts, GL_UNSIGNED_INT, (void *) 0);
|
||||
}
|
||||
glFinish();
|
||||
PerfSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
/** Called from test harness/main */
|
||||
void
|
||||
PerfDraw(void)
|
||||
{
|
||||
double rate;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
printf("Vertex rate (%d x Vertex%df)\n", NumVerts, VERT_SIZE);
|
||||
|
||||
rate = PerfMeasureRate(DrawImmediate);
|
||||
rate *= NumVerts;
|
||||
printf(" Immediate mode: %.1f verts/sec\n", rate);
|
||||
|
||||
rate = PerfMeasureRate(DrawArraysMem);
|
||||
rate *= NumVerts;
|
||||
printf(" glDrawArrays: %.1f verts/sec\n", rate);
|
||||
|
||||
rate = PerfMeasureRate(DrawArraysVBO);
|
||||
rate *= NumVerts;
|
||||
printf(" VBO glDrawArrays: %.1f verts/sec\n", rate);
|
||||
|
||||
rate = PerfMeasureRate(DrawElementsMem);
|
||||
rate *= NumVerts;
|
||||
printf(" glDrawElements: %.1f verts/sec\n", rate);
|
||||
|
||||
rate = PerfMeasureRate(DrawElementsBO);
|
||||
rate *= NumVerts;
|
||||
printf(" VBO glDrawElements: %.1f verts/sec\n", rate);
|
||||
|
||||
rate = PerfMeasureRate(DrawRangeElementsMem);
|
||||
rate *= NumVerts;
|
||||
printf(" glDrawRangeElements: %.1f verts/sec\n", rate);
|
||||
|
||||
rate = PerfMeasureRate(DrawRangeElementsBO);
|
||||
rate *= NumVerts;
|
||||
printf(" VBO glDrawRangeElements: %.1f verts/sec\n", rate);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -13,14 +13,16 @@
|
|||
|
||||
static GLint WinWidth = 500, WinHeight = 500;
|
||||
static GLboolean Invert = GL_FALSE;
|
||||
static GLboolean TestPacking = GL_FALSE;
|
||||
static GLboolean TestList = GL_FALSE;
|
||||
|
||||
|
||||
static void Display(void)
|
||||
{
|
||||
GLfloat depth[100 * 100];
|
||||
GLfloat depth2[400 * 400];
|
||||
GLfloat min, max;
|
||||
int i;
|
||||
GLfloat depth[100 * 100 * 2];
|
||||
GLfloat depth2[400 * 400]; /* *2 to test pixelstore stuff */
|
||||
GLuint list;
|
||||
GLenum depthType = GL_FLOAT;
|
||||
|
||||
glClearColor(0.5, 0.5, 0.5, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
|
@ -36,16 +38,32 @@ static void Display(void)
|
|||
glLoadIdentity();
|
||||
glutSolidSphere(1.0, 20, 10);
|
||||
|
||||
/* read the depth image */
|
||||
glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
|
||||
min = max = depth[0];
|
||||
for (i = 1; i < 100 * 100; i++) {
|
||||
if (depth[i] < min)
|
||||
min = depth[i];
|
||||
if (depth[i] > max)
|
||||
max = depth[i];
|
||||
if (TestPacking) {
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 120);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, 5);
|
||||
}
|
||||
|
||||
/* read the depth image */
|
||||
glReadPixels(0, 0, 100, 100, GL_DEPTH_COMPONENT, depthType, depth);
|
||||
if (depthType == GL_FLOAT) {
|
||||
GLfloat min, max;
|
||||
int i;
|
||||
min = max = depth[0];
|
||||
for (i = 1; i < 100 * 100; i++) {
|
||||
if (depth[i] < min)
|
||||
min = depth[i];
|
||||
if (depth[i] > max)
|
||||
max = depth[i];
|
||||
}
|
||||
printf("Depth value range: [%f, %f]\n", min, max);
|
||||
}
|
||||
|
||||
if (TestPacking) {
|
||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 120);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 5);
|
||||
}
|
||||
printf("Depth value range: [%f, %f]\n", min, max);
|
||||
|
||||
/* draw depth image with scaling (into z buffer) */
|
||||
glPixelZoom(4.0, 4.0);
|
||||
|
|
@ -55,12 +73,27 @@ static void Display(void)
|
|||
glPixelTransferf(GL_DEPTH_SCALE, -1.0);
|
||||
glPixelTransferf(GL_DEPTH_BIAS, 1.0);
|
||||
}
|
||||
glDrawPixels(100, 100, GL_DEPTH_COMPONENT, GL_FLOAT, depth);
|
||||
if (TestList) {
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
glDrawPixels(100, 100, GL_DEPTH_COMPONENT, depthType, depth);
|
||||
glEndList();
|
||||
glCallList(list);
|
||||
glDeleteLists(list, 1);
|
||||
}
|
||||
else {
|
||||
glDrawPixels(100, 100, GL_DEPTH_COMPONENT, depthType, depth);
|
||||
}
|
||||
if (Invert) {
|
||||
glPixelTransferf(GL_DEPTH_SCALE, 1.0);
|
||||
glPixelTransferf(GL_DEPTH_BIAS, 0.0);
|
||||
}
|
||||
|
||||
if (TestPacking) {
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
}
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
/* read back scaled depth image */
|
||||
|
|
@ -89,6 +122,14 @@ static void Key(unsigned char key, int x, int y)
|
|||
case 'i':
|
||||
Invert = !Invert;
|
||||
break;
|
||||
case 'p':
|
||||
TestPacking = !TestPacking;
|
||||
printf("Test pixel pack/unpack: %d\n", TestPacking);
|
||||
break;
|
||||
case 'l':
|
||||
TestList = !TestList;
|
||||
printf("Test dlist: %d\n", TestList);
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -119,6 +119,12 @@ static void Init( void )
|
|||
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
|
||||
glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
sz, (const GLubyte *) buf);
|
||||
if (glGetError()) {
|
||||
printf("Program failed to compile:\n%s\n", buf);
|
||||
printf("Error: %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
exit(1);
|
||||
}
|
||||
assert(glIsProgramARB(prognum));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,11 +52,20 @@ def generate(env):
|
|||
target_cpu = 'x64'
|
||||
else:
|
||||
raise SCons.Errors.InternalError, "Unsupported target machine"
|
||||
include_dir = 'Include'
|
||||
|
||||
include_dir = os.path.join(dxsdk_root, 'Include')
|
||||
lib_dir = os.path.join(dxsdk_root, 'Lib', target_cpu)
|
||||
|
||||
env.Append(CPPDEFINES = [('HAVE_DXSDK', '1')])
|
||||
env.Prepend(CPPPATH = [os.path.join(dxsdk_root, 'Include')])
|
||||
env.Prepend(LIBPATH = [os.path.join(dxsdk_root, 'Lib', target_cpu)])
|
||||
|
||||
gcc = 'gcc' in os.path.basename(env['CC']).split('-')
|
||||
if gcc:
|
||||
# Make GCC more forgiving towards Microsoft's headers
|
||||
env.Prepend(CPPFLAGS = ['-isystem', include_dir])
|
||||
else:
|
||||
env.Prepend(CPPPATH = [include_dir])
|
||||
|
||||
env.Prepend(LIBPATH = [lib_dir])
|
||||
|
||||
def exists(env):
|
||||
return get_dxsdk_root(env) is not None
|
||||
|
|
|
|||
|
|
@ -51,7 +51,9 @@ def generate(env):
|
|||
|
||||
llvm_bin_dir = os.path.join(llvm_dir, llvm_subdir, 'bin')
|
||||
if not os.path.isdir(llvm_bin_dir):
|
||||
raise SCons.Errors.InternalError, "LLVM build directory not found"
|
||||
llvm_bin_dir = os.path.join(llvm_dir, 'bin')
|
||||
if not os.path.isdir(llvm_bin_dir):
|
||||
raise SCons.Errors.InternalError, "LLVM binary directory not found"
|
||||
|
||||
env.PrependENVPath('PATH', llvm_bin_dir)
|
||||
|
||||
|
|
@ -65,6 +67,8 @@ def generate(env):
|
|||
except OSError:
|
||||
print 'llvm-config version %s failed' % version
|
||||
else:
|
||||
if env['platform'] == 'windows':
|
||||
env.Append(LIBS = ['imagehlp', 'psapi'])
|
||||
env['LINK'] = env['CXX']
|
||||
env['LLVM_VERSION'] = version
|
||||
|
||||
|
|
|
|||
|
|
@ -85,8 +85,6 @@ def get_winddk_paths(env, version, root):
|
|||
else:
|
||||
# TODO: take in consideration the host cpu
|
||||
bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
|
||||
|
||||
env.PrependENVPath('PATH', [bin_dir])
|
||||
|
||||
crt_inc_dir = os.path.join(root, 'inc', 'crt')
|
||||
if version_major >= 6000:
|
||||
|
|
@ -98,17 +96,33 @@ def get_winddk_paths(env, version, root):
|
|||
sdk_inc_dir = os.path.join(root, 'inc', target_os)
|
||||
wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
|
||||
|
||||
env.PrependENVPath('INCLUDE', [
|
||||
wdm_inc_dir,
|
||||
ddk_inc_dir,
|
||||
crt_inc_dir,
|
||||
sdk_inc_dir,
|
||||
])
|
||||
if env['toolchain'] == 'winddk':
|
||||
env.PrependENVPath('PATH', [bin_dir])
|
||||
env.PrependENVPath('INCLUDE', [
|
||||
wdm_inc_dir,
|
||||
ddk_inc_dir,
|
||||
crt_inc_dir,
|
||||
sdk_inc_dir,
|
||||
])
|
||||
env.PrependENVPath('LIB', [
|
||||
os.path.join(root, 'lib', 'crt', target_cpu),
|
||||
os.path.join(root, 'lib', target_os, target_cpu),
|
||||
])
|
||||
elif env['toolchain'] == 'crossmingw':
|
||||
env.Prepend(CPPFLAGS = [
|
||||
'-isystem', ddk_inc_dir,
|
||||
'-isystem', sdk_inc_dir,
|
||||
])
|
||||
else:
|
||||
env.Prepend(CPPPATH = [
|
||||
wdm_inc_dir,
|
||||
ddk_inc_dir,
|
||||
sdk_inc_dir,
|
||||
])
|
||||
env.Prepend(LIBPATH = [
|
||||
os.path.join(root, 'lib', target_os, target_cpu),
|
||||
])
|
||||
|
||||
env.PrependENVPath('LIB', [
|
||||
os.path.join(root, 'lib', 'crt', target_cpu),
|
||||
os.path.join(root, 'lib', target_os, target_cpu),
|
||||
])
|
||||
|
||||
def generate(env):
|
||||
if not env.has_key('ENV'):
|
||||
|
|
@ -120,9 +134,10 @@ def generate(env):
|
|||
get_winddk_paths(env, version, root)
|
||||
break
|
||||
|
||||
msvc_sa.generate(env)
|
||||
mslib_sa.generate(env)
|
||||
mslink_sa.generate(env)
|
||||
if env['toolchain'] == 'winddk':
|
||||
msvc_sa.generate(env)
|
||||
mslib_sa.generate(env)
|
||||
mslink_sa.generate(env)
|
||||
|
||||
def exists(env):
|
||||
for version in versions:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ PIPE_FORMAT_A8R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , zyxw,
|
|||
PIPE_FORMAT_X8R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb
|
||||
PIPE_FORMAT_A1R5G5B5_UNORM , arith , 1, 1, un1 , un5 , un5 , un5 , zyxw, rgb
|
||||
PIPE_FORMAT_A1R5G5B5_UNORM , arith , 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
|
||||
PIPE_FORMAT_A4R4G4B4_UNORM , arith , 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
|
||||
PIPE_FORMAT_R5G6B5_UNORM , arith , 1, 1, un5 , un6 , un5 , , zyx1, rgb
|
||||
PIPE_FORMAT_A2B10G10R10_UNORM , arith , 1, 1, un10, un10, un10, un2 , xyzw, rgb
|
||||
|
|
|
|||
|
|
|
@ -354,7 +354,9 @@ util_is_pot(unsigned x)
|
|||
* Find first bit set in word. Least significant bit is 1.
|
||||
* Return 0 if no bits set.
|
||||
*/
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1300
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1300 && (_M_IX86 || _M_AMD64 || _M_IA64)
|
||||
unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
|
||||
#pragma intrinsic(_BitScanForward)
|
||||
static INLINE
|
||||
unsigned long ffs( unsigned long u )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,8 +64,6 @@ cell_get_param(struct pipe_screen *screen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 1;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 0;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -101,8 +101,6 @@ i915_get_param(struct pipe_screen *screen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 0;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -85,8 +85,6 @@ brw_get_param(struct pipe_screen *screen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 0;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ include $(TOP)/configs/current
|
|||
|
||||
LIBNAME = llvmpipe
|
||||
|
||||
CFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
|
||||
|
||||
C_SOURCES = \
|
||||
lp_bld_alpha.c \
|
||||
lp_bld_arit.c \
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ Import('*')
|
|||
env = env.Clone()
|
||||
|
||||
env.Tool('llvm')
|
||||
if env.has_key('LLVM_VERSION') is False:
|
||||
if not env.has_key('LLVM_VERSION'):
|
||||
print 'warning: LLVM not found: not building llvmpipe'
|
||||
Return()
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
void
|
||||
lp_build_alpha_test(LLVMBuilderRef builder,
|
||||
const struct pipe_alpha_state *state,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef alpha,
|
||||
LLVMValueRef ref)
|
||||
|
|
|
|||
|
|
@ -38,14 +38,14 @@
|
|||
#include <llvm-c/Core.h>
|
||||
|
||||
struct pipe_alpha_state;
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
struct lp_build_mask_context;
|
||||
|
||||
|
||||
void
|
||||
lp_build_alpha_test(LLVMBuilderRef builder,
|
||||
const struct pipe_alpha_state *state,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef alpha,
|
||||
LLVMValueRef ref);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ lp_build_min_simple(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
const char *intrinsic = NULL;
|
||||
LLVMValueRef cond;
|
||||
|
||||
|
|
@ -113,7 +113,7 @@ lp_build_max_simple(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
const char *intrinsic = NULL;
|
||||
LLVMValueRef cond;
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ LLVMValueRef
|
|||
lp_build_comp(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
if(a == bld->one)
|
||||
return bld->zero;
|
||||
|
|
@ -188,7 +188,7 @@ lp_build_add(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMValueRef res;
|
||||
|
||||
if(a == bld->zero)
|
||||
|
|
@ -241,7 +241,7 @@ lp_build_sub(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMValueRef res;
|
||||
|
||||
if(b == bld->zero)
|
||||
|
|
@ -405,7 +405,7 @@ lp_build_mul(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
if(a == bld->zero)
|
||||
return bld->zero;
|
||||
|
|
@ -477,7 +477,7 @@ lp_build_div(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
if(a == bld->zero)
|
||||
return bld->zero;
|
||||
|
|
@ -590,7 +590,7 @@ LLVMValueRef
|
|||
lp_build_abs(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
|
||||
if(!type.sign)
|
||||
|
|
@ -627,7 +627,7 @@ LLVMValueRef
|
|||
lp_build_sgn(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
LLVMValueRef cond;
|
||||
LLVMValueRef res;
|
||||
|
|
@ -678,7 +678,7 @@ lp_build_round_sse41(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
enum lp_build_round_sse41_mode mode)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
const char *intrinsic;
|
||||
|
||||
|
|
@ -706,7 +706,7 @@ LLVMValueRef
|
|||
lp_build_round(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
assert(type.floating);
|
||||
|
||||
|
|
@ -724,7 +724,7 @@ LLVMValueRef
|
|||
lp_build_floor(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
assert(type.floating);
|
||||
|
||||
|
|
@ -742,7 +742,7 @@ LLVMValueRef
|
|||
lp_build_ceil(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
assert(type.floating);
|
||||
|
||||
|
|
@ -760,7 +760,7 @@ LLVMValueRef
|
|||
lp_build_trunc(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
assert(type.floating);
|
||||
|
||||
|
|
@ -782,7 +782,7 @@ LLVMValueRef
|
|||
lp_build_int(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
|
||||
|
||||
assert(type.floating);
|
||||
|
|
@ -805,7 +805,7 @@ LLVMValueRef
|
|||
lp_build_sqrt(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
char intrinsic[32];
|
||||
|
||||
|
|
@ -823,7 +823,7 @@ LLVMValueRef
|
|||
lp_build_rcp(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
if(a == bld->zero)
|
||||
return bld->undef;
|
||||
|
|
@ -854,7 +854,7 @@ LLVMValueRef
|
|||
lp_build_rsqrt(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
|
||||
assert(type.floating);
|
||||
|
||||
|
|
@ -875,7 +875,7 @@ LLVMValueRef
|
|||
lp_build_cos(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
char intrinsic[32];
|
||||
|
||||
|
|
@ -895,7 +895,7 @@ LLVMValueRef
|
|||
lp_build_sin(struct lp_build_context *bld,
|
||||
LLVMValueRef a)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
char intrinsic[32];
|
||||
|
||||
|
|
@ -966,7 +966,7 @@ lp_build_polynomial(struct lp_build_context *bld,
|
|||
const double *coeffs,
|
||||
unsigned num_coeffs)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMValueRef res = NULL;
|
||||
unsigned i;
|
||||
|
||||
|
|
@ -1014,7 +1014,7 @@ lp_build_exp2_approx(struct lp_build_context *bld,
|
|||
LLVMValueRef *p_frac_part,
|
||||
LLVMValueRef *p_exp2)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
|
||||
LLVMValueRef ipart = NULL;
|
||||
|
|
@ -1107,7 +1107,7 @@ lp_build_log2_approx(struct lp_build_context *bld,
|
|||
LLVMValueRef *p_floor_log2,
|
||||
LLVMValueRef *p_log2)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include <llvm-c/Core.h>
|
||||
|
||||
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
struct lp_build_context;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
|
||||
struct pipe_blend_state;
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
struct lp_build_context;
|
||||
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ lp_build_blend_func(struct lp_build_context *bld,
|
|||
LLVMValueRef
|
||||
lp_build_blend_aos(LLVMBuilderRef builder,
|
||||
const struct pipe_blend_state *blend,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef src,
|
||||
LLVMValueRef dst,
|
||||
LLVMValueRef const_,
|
||||
|
|
@ -84,7 +84,7 @@ lp_build_blend_aos(LLVMBuilderRef builder,
|
|||
void
|
||||
lp_build_blend_soa(LLVMBuilderRef builder,
|
||||
const struct pipe_blend_state *blend,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef src[4],
|
||||
LLVMValueRef dst[4],
|
||||
LLVMValueRef const_[4],
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ lp_build_blend_func(struct lp_build_context *bld,
|
|||
LLVMValueRef
|
||||
lp_build_blend_aos(LLVMBuilderRef builder,
|
||||
const struct pipe_blend_state *blend,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef src,
|
||||
LLVMValueRef dst,
|
||||
LLVMValueRef const_,
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ lp_build_blend_soa_factor(struct lp_build_blend_soa_context *bld,
|
|||
void
|
||||
lp_build_blend_soa(LLVMBuilderRef builder,
|
||||
const struct pipe_blend_state *blend,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef src[4],
|
||||
LLVMValueRef dst[4],
|
||||
LLVMValueRef con[4],
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
|
||||
unsigned
|
||||
lp_mantissa(union lp_type type)
|
||||
lp_mantissa(struct lp_type type)
|
||||
{
|
||||
assert(type.floating);
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ lp_mantissa(union lp_type type)
|
|||
* Same as lp_const_scale(), but in terms of shifts.
|
||||
*/
|
||||
unsigned
|
||||
lp_const_shift(union lp_type type)
|
||||
lp_const_shift(struct lp_type type)
|
||||
{
|
||||
if(type.floating)
|
||||
return 0;
|
||||
|
|
@ -86,7 +86,7 @@ lp_const_shift(union lp_type type)
|
|||
|
||||
|
||||
unsigned
|
||||
lp_const_offset(union lp_type type)
|
||||
lp_const_offset(struct lp_type type)
|
||||
{
|
||||
if(type.floating || type.fixed)
|
||||
return 0;
|
||||
|
|
@ -104,7 +104,7 @@ lp_const_offset(union lp_type type)
|
|||
* else for the fixed points types and normalized integers.
|
||||
*/
|
||||
double
|
||||
lp_const_scale(union lp_type type)
|
||||
lp_const_scale(struct lp_type type)
|
||||
{
|
||||
unsigned long long llscale;
|
||||
double dscale;
|
||||
|
|
@ -122,7 +122,7 @@ lp_const_scale(union lp_type type)
|
|||
* Minimum value representable by the type.
|
||||
*/
|
||||
double
|
||||
lp_const_min(union lp_type type)
|
||||
lp_const_min(struct lp_type type)
|
||||
{
|
||||
unsigned bits;
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ lp_const_min(union lp_type type)
|
|||
* Maximum value representable by the type.
|
||||
*/
|
||||
double
|
||||
lp_const_max(union lp_type type)
|
||||
lp_const_max(struct lp_type type)
|
||||
{
|
||||
unsigned bits;
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ lp_const_max(union lp_type type)
|
|||
|
||||
|
||||
double
|
||||
lp_const_eps(union lp_type type)
|
||||
lp_const_eps(struct lp_type type)
|
||||
{
|
||||
if (type.floating) {
|
||||
switch(type.width) {
|
||||
|
|
@ -211,7 +211,7 @@ lp_const_eps(union lp_type type)
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_undef(union lp_type type)
|
||||
lp_build_undef(struct lp_type type)
|
||||
{
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
return LLVMGetUndef(vec_type);
|
||||
|
|
@ -219,7 +219,7 @@ lp_build_undef(union lp_type type)
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_zero(union lp_type type)
|
||||
lp_build_zero(struct lp_type type)
|
||||
{
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
return LLVMConstNull(vec_type);
|
||||
|
|
@ -227,7 +227,7 @@ lp_build_zero(union lp_type type)
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_one(union lp_type type)
|
||||
lp_build_one(struct lp_type type)
|
||||
{
|
||||
LLVMTypeRef elem_type;
|
||||
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH];
|
||||
|
|
@ -269,7 +269,7 @@ lp_build_one(union lp_type type)
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_const_scalar(union lp_type type,
|
||||
lp_build_const_scalar(struct lp_type type,
|
||||
double val)
|
||||
{
|
||||
LLVMTypeRef elem_type = lp_build_elem_type(type);
|
||||
|
|
@ -295,7 +295,7 @@ lp_build_const_scalar(union lp_type type,
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_int_const_scalar(union lp_type type,
|
||||
lp_build_int_const_scalar(struct lp_type type,
|
||||
long long val)
|
||||
{
|
||||
LLVMTypeRef elem_type = lp_build_int_elem_type(type);
|
||||
|
|
@ -312,7 +312,7 @@ lp_build_int_const_scalar(union lp_type type,
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_const_aos(union lp_type type,
|
||||
lp_build_const_aos(struct lp_type type,
|
||||
double r, double g, double b, double a,
|
||||
const unsigned char *swizzle)
|
||||
{
|
||||
|
|
@ -352,8 +352,8 @@ lp_build_const_aos(union lp_type type,
|
|||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_const_mask_aos(union lp_type type,
|
||||
boolean cond[4])
|
||||
lp_build_const_mask_aos(struct lp_type type,
|
||||
const boolean cond[4])
|
||||
{
|
||||
LLVMTypeRef elem_type = LLVMIntType(type.width);
|
||||
LLVMValueRef masks[LP_MAX_VECTOR_LENGTH];
|
||||
|
|
|
|||
|
|
@ -42,67 +42,67 @@
|
|||
#include <pipe/p_compiler.h>
|
||||
|
||||
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
|
||||
|
||||
unsigned
|
||||
lp_mantissa(union lp_type type);
|
||||
lp_mantissa(struct lp_type type);
|
||||
|
||||
|
||||
unsigned
|
||||
lp_const_shift(union lp_type type);
|
||||
lp_const_shift(struct lp_type type);
|
||||
|
||||
|
||||
unsigned
|
||||
lp_const_offset(union lp_type type);
|
||||
lp_const_offset(struct lp_type type);
|
||||
|
||||
|
||||
double
|
||||
lp_const_scale(union lp_type type);
|
||||
lp_const_scale(struct lp_type type);
|
||||
|
||||
double
|
||||
lp_const_min(union lp_type type);
|
||||
lp_const_min(struct lp_type type);
|
||||
|
||||
|
||||
double
|
||||
lp_const_max(union lp_type type);
|
||||
lp_const_max(struct lp_type type);
|
||||
|
||||
|
||||
double
|
||||
lp_const_eps(union lp_type type);
|
||||
lp_const_eps(struct lp_type type);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_undef(union lp_type type);
|
||||
lp_build_undef(struct lp_type type);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_zero(union lp_type type);
|
||||
lp_build_zero(struct lp_type type);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_one(union lp_type type);
|
||||
lp_build_one(struct lp_type type);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_const_scalar(union lp_type type,
|
||||
lp_build_const_scalar(struct lp_type type,
|
||||
double val);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_int_const_scalar(union lp_type type,
|
||||
lp_build_int_const_scalar(struct lp_type type,
|
||||
long long val);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_const_aos(union lp_type type,
|
||||
lp_build_const_aos(struct lp_type type,
|
||||
double r, double g, double b, double a,
|
||||
const unsigned char *swizzle);
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_const_mask_aos(union lp_type type,
|
||||
boolean cond[4]);
|
||||
lp_build_const_mask_aos(struct lp_type type,
|
||||
const boolean cond[4]);
|
||||
|
||||
|
||||
#endif /* !LP_BLD_CONST_H */
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
*/
|
||||
LLVMValueRef
|
||||
lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
struct lp_type src_type,
|
||||
unsigned dst_width,
|
||||
LLVMValueRef src)
|
||||
{
|
||||
|
|
@ -152,7 +152,7 @@ lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
|
|||
LLVMValueRef
|
||||
lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
|
||||
unsigned src_width,
|
||||
union lp_type dst_type,
|
||||
struct lp_type dst_type,
|
||||
LLVMValueRef src)
|
||||
{
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(dst_type);
|
||||
|
|
@ -248,8 +248,8 @@ lp_build_const_pack_shuffle(unsigned n)
|
|||
*/
|
||||
static void
|
||||
lp_build_expand(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
LLVMValueRef src,
|
||||
LLVMValueRef *dst, unsigned num_dsts)
|
||||
{
|
||||
|
|
@ -266,7 +266,7 @@ lp_build_expand(LLVMBuilderRef builder,
|
|||
dst[0] = src;
|
||||
|
||||
while(src_type.width < dst_type.width) {
|
||||
union lp_type new_type = src_type;
|
||||
struct lp_type new_type = src_type;
|
||||
LLVMTypeRef new_vec_type;
|
||||
|
||||
new_type.width *= 2;
|
||||
|
|
@ -314,8 +314,8 @@ lp_build_expand(LLVMBuilderRef builder,
|
|||
*/
|
||||
static LLVMValueRef
|
||||
lp_build_pack2(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
boolean clamped,
|
||||
LLVMValueRef lo,
|
||||
LLVMValueRef hi)
|
||||
|
|
@ -392,8 +392,8 @@ lp_build_pack2(LLVMBuilderRef builder,
|
|||
*/
|
||||
static LLVMValueRef
|
||||
lp_build_pack(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
boolean clamped,
|
||||
const LLVMValueRef *src, unsigned num_srcs)
|
||||
{
|
||||
|
|
@ -410,7 +410,7 @@ lp_build_pack(LLVMBuilderRef builder,
|
|||
tmp[i] = src[i];
|
||||
|
||||
while(src_type.width > dst_type.width) {
|
||||
union lp_type new_type = src_type;
|
||||
struct lp_type new_type = src_type;
|
||||
|
||||
new_type.width /= 2;
|
||||
new_type.length *= 2;
|
||||
|
|
@ -442,12 +442,12 @@ lp_build_pack(LLVMBuilderRef builder,
|
|||
*/
|
||||
void
|
||||
lp_build_conv(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
const LLVMValueRef *src, unsigned num_srcs,
|
||||
LLVMValueRef *dst, unsigned num_dsts)
|
||||
{
|
||||
union lp_type tmp_type;
|
||||
struct lp_type tmp_type;
|
||||
LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH];
|
||||
unsigned num_tmps;
|
||||
unsigned i;
|
||||
|
|
@ -470,7 +470,7 @@ lp_build_conv(LLVMBuilderRef builder,
|
|||
* Clamp if necessary
|
||||
*/
|
||||
|
||||
if(src_type.value != dst_type.value) {
|
||||
if(memcmp(&src_type, &dst_type, sizeof src_type) != 0) {
|
||||
struct lp_build_context bld;
|
||||
double src_min = lp_const_min(src_type);
|
||||
double dst_min = lp_const_min(dst_type);
|
||||
|
|
@ -656,8 +656,8 @@ lp_build_conv(LLVMBuilderRef builder,
|
|||
*/
|
||||
void
|
||||
lp_build_conv_mask(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
const LLVMValueRef *src, unsigned num_srcs,
|
||||
LLVMValueRef *dst, unsigned num_dsts)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,33 +40,33 @@
|
|||
#include <llvm-c/Core.h>
|
||||
|
||||
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_clamped_float_to_unsigned_norm(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
struct lp_type src_type,
|
||||
unsigned dst_width,
|
||||
LLVMValueRef src);
|
||||
|
||||
LLVMValueRef
|
||||
lp_build_unsigned_norm_to_float(LLVMBuilderRef builder,
|
||||
unsigned src_width,
|
||||
union lp_type dst_type,
|
||||
struct lp_type dst_type,
|
||||
LLVMValueRef src);
|
||||
|
||||
|
||||
void
|
||||
lp_build_conv(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
const LLVMValueRef *srcs, unsigned num_srcs,
|
||||
LLVMValueRef *dsts, unsigned num_dsts);
|
||||
|
||||
void
|
||||
lp_build_conv_mask(LLVMBuilderRef builder,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
const LLVMValueRef *src, unsigned num_srcs,
|
||||
LLVMValueRef *dst, unsigned num_dsts);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@
|
|||
/**
|
||||
* Return a type appropriate for depth/stencil testing.
|
||||
*/
|
||||
union lp_type
|
||||
struct lp_type
|
||||
lp_depth_type(const struct util_format_description *format_desc,
|
||||
unsigned length)
|
||||
{
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
unsigned swizzle;
|
||||
|
||||
assert(format_desc->colorspace == UTIL_FORMAT_COLORSPACE_ZS);
|
||||
|
|
@ -85,7 +85,7 @@ lp_depth_type(const struct util_format_description *format_desc,
|
|||
swizzle = format_desc->swizzle[0];
|
||||
assert(swizzle < 4);
|
||||
|
||||
type.value = 0;
|
||||
memset(&type, 0, sizeof type);
|
||||
type.width = format_desc->block.bits;
|
||||
|
||||
if(format_desc->channel[swizzle].type == UTIL_FORMAT_TYPE_FLOAT) {
|
||||
|
|
@ -114,7 +114,7 @@ lp_depth_type(const struct util_format_description *format_desc,
|
|||
void
|
||||
lp_build_depth_test(LLVMBuilderRef builder,
|
||||
const struct pipe_depth_state *state,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
const struct util_format_description *format_desc,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef src,
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@
|
|||
|
||||
struct pipe_depth_state;
|
||||
struct util_format_description;
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
struct lp_build_mask_context;
|
||||
|
||||
|
||||
union lp_type
|
||||
struct lp_type
|
||||
lp_depth_type(const struct util_format_description *format_desc,
|
||||
unsigned length);
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ lp_depth_type(const struct util_format_description *format_desc,
|
|||
void
|
||||
lp_build_depth_test(LLVMBuilderRef builder,
|
||||
const struct pipe_depth_state *state,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
const struct util_format_description *format_desc,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef src,
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ lp_build_mask_check(struct lp_build_mask_context *mask)
|
|||
void
|
||||
lp_build_mask_begin(struct lp_build_mask_context *mask,
|
||||
struct lp_build_flow_context *flow,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef value)
|
||||
{
|
||||
memset(mask, 0, sizeof *mask);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
#include <llvm-c/Core.h>
|
||||
|
||||
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
|
||||
|
||||
struct lp_build_flow_context;
|
||||
|
|
@ -84,7 +84,7 @@ struct lp_build_mask_context
|
|||
void
|
||||
lp_build_mask_begin(struct lp_build_mask_context *mask,
|
||||
struct lp_build_flow_context *flow,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef value);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "pipe/p_format.h"
|
||||
|
||||
struct util_format_description;
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -103,7 +103,7 @@ lp_build_gather(LLVMBuilderRef builder,
|
|||
void
|
||||
lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
|
||||
const struct util_format_description *format_desc,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef packed,
|
||||
LLVMValueRef *rgba);
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
|
|||
void
|
||||
lp_build_load_rgba_soa(LLVMBuilderRef builder,
|
||||
const struct util_format_description *format_desc,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef base_ptr,
|
||||
LLVMValueRef offsets,
|
||||
LLVMValueRef *rgba);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ lp_build_gather(LLVMBuilderRef builder,
|
|||
|
||||
|
||||
static LLVMValueRef
|
||||
lp_build_format_swizzle(union lp_type type,
|
||||
lp_build_format_swizzle(struct lp_type type,
|
||||
const LLVMValueRef *inputs,
|
||||
enum util_format_swizzle swizzle)
|
||||
{
|
||||
|
|
@ -110,7 +110,7 @@ lp_build_format_swizzle(union lp_type type,
|
|||
void
|
||||
lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
|
||||
const struct util_format_description *format_desc,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef packed,
|
||||
LLVMValueRef *rgba)
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
|
|||
void
|
||||
lp_build_load_rgba_soa(LLVMBuilderRef builder,
|
||||
const struct util_format_description *format_desc,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef base_ptr,
|
||||
LLVMValueRef offsets,
|
||||
LLVMValueRef *rgba)
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ void
|
|||
lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
|
||||
const struct tgsi_token *tokens,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef a0_ptr,
|
||||
LLVMValueRef dadx_ptr,
|
||||
LLVMValueRef dady_ptr,
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ void
|
|||
lp_build_interp_soa_init(struct lp_build_interp_soa_context *bld,
|
||||
const struct tgsi_token *tokens,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef a0_ptr,
|
||||
LLVMValueRef dadx_ptr,
|
||||
LLVMValueRef dady_ptr,
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ lp_build_cmp(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMTypeRef vec_type = lp_build_vec_type(type);
|
||||
LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
|
||||
LLVMValueRef zeros = LLVMConstNull(int_vec_type);
|
||||
|
|
@ -301,7 +301,7 @@ lp_build_select(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
union lp_type type = bld->type;
|
||||
struct lp_type type = bld->type;
|
||||
LLVMValueRef res;
|
||||
|
||||
if(a == b)
|
||||
|
|
@ -339,7 +339,7 @@ lp_build_select_aos(struct lp_build_context *bld,
|
|||
LLVMValueRef b,
|
||||
const boolean cond[4])
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
const unsigned n = type.length;
|
||||
unsigned i, j;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
#include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */
|
||||
|
||||
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
struct lp_build_context;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
struct pipe_texture;
|
||||
struct pipe_sampler_state;
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -123,7 +123,7 @@ void
|
|||
lp_build_sample_soa(LLVMBuilderRef builder,
|
||||
const struct lp_sampler_static_state *static_state,
|
||||
struct lp_sampler_dynamic_state *dynamic_state,
|
||||
union lp_type fp_type,
|
||||
struct lp_type fp_type,
|
||||
unsigned unit,
|
||||
unsigned num_coords,
|
||||
const LLVMValueRef *coords,
|
||||
|
|
|
|||
|
|
@ -97,15 +97,15 @@ struct lp_build_sample_context
|
|||
const struct util_format_description *format_desc;
|
||||
|
||||
/** Incoming coordinates type and build context */
|
||||
union lp_type coord_type;
|
||||
struct lp_type coord_type;
|
||||
struct lp_build_context coord_bld;
|
||||
|
||||
/** Integer coordinates */
|
||||
union lp_type int_coord_type;
|
||||
struct lp_type int_coord_type;
|
||||
struct lp_build_context int_coord_bld;
|
||||
|
||||
/** Output texels type and build context */
|
||||
union lp_type texel_type;
|
||||
struct lp_type texel_type;
|
||||
struct lp_build_context texel_bld;
|
||||
};
|
||||
|
||||
|
|
@ -208,6 +208,11 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld,
|
|||
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
|
||||
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
|
||||
/* FIXME */
|
||||
_debug_printf("warning: failed to translate texture wrap mode %u\n", wrap_mode);
|
||||
coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero);
|
||||
coord = lp_build_min(int_coord_bld, coord, length_minus_one);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
|
@ -337,7 +342,7 @@ void
|
|||
lp_build_sample_soa(LLVMBuilderRef builder,
|
||||
const struct lp_sampler_static_state *static_state,
|
||||
struct lp_sampler_dynamic_state *dynamic_state,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
unsigned unit,
|
||||
unsigned num_coords,
|
||||
const LLVMValueRef *coords,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ LLVMValueRef
|
|||
lp_build_broadcast_scalar(struct lp_build_context *bld,
|
||||
LLVMValueRef scalar)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
LLVMValueRef res;
|
||||
unsigned i;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
|
|||
LLVMValueRef a,
|
||||
unsigned channel)
|
||||
{
|
||||
const union lp_type type = bld->type;
|
||||
const struct lp_type type = bld->type;
|
||||
const unsigned n = type.length;
|
||||
unsigned i, j;
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ lp_build_broadcast_aos(struct lp_build_context *bld,
|
|||
* YY00 YY00 .... YY00
|
||||
* YYYY YYYY .... YYYY <= output
|
||||
*/
|
||||
union lp_type type4 = type;
|
||||
struct lp_type type4 = type;
|
||||
const char shifts[4][2] = {
|
||||
{ 1, 2},
|
||||
{-1, 2},
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include <llvm-c/Core.h>
|
||||
|
||||
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
struct lp_build_context;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
|
||||
struct tgsi_token;
|
||||
union lp_type;
|
||||
struct lp_type;
|
||||
struct lp_build_context;
|
||||
struct lp_build_mask_context;
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ struct lp_build_sampler_soa
|
|||
void
|
||||
(*emit_fetch_texel)( struct lp_build_sampler_soa *sampler,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
unsigned unit,
|
||||
unsigned num_coords,
|
||||
const LLVMValueRef *coords,
|
||||
|
|
@ -72,7 +72,7 @@ struct lp_build_sampler_soa
|
|||
void
|
||||
lp_build_tgsi_soa(LLVMBuilderRef builder,
|
||||
const struct tgsi_token *tokens,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef consts_ptr,
|
||||
const LLVMValueRef *pos,
|
||||
|
|
|
|||
|
|
@ -1415,7 +1415,7 @@ emit_instruction(
|
|||
void
|
||||
lp_build_tgsi_soa(LLVMBuilderRef builder,
|
||||
const struct tgsi_token *tokens,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef consts_ptr,
|
||||
const LLVMValueRef *pos,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_elem_type(union lp_type type)
|
||||
lp_build_elem_type(struct lp_type type)
|
||||
{
|
||||
if (type.floating) {
|
||||
switch(type.width) {
|
||||
|
|
@ -55,7 +55,7 @@ lp_build_elem_type(union lp_type type)
|
|||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_vec_type(union lp_type type)
|
||||
lp_build_vec_type(struct lp_type type)
|
||||
{
|
||||
LLVMTypeRef elem_type = lp_build_elem_type(type);
|
||||
return LLVMVectorType(elem_type, type.length);
|
||||
|
|
@ -69,7 +69,7 @@ lp_build_vec_type(union lp_type type)
|
|||
* type and check for identity.
|
||||
*/
|
||||
boolean
|
||||
lp_check_elem_type(union lp_type type, LLVMTypeRef elem_type)
|
||||
lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type)
|
||||
{
|
||||
LLVMTypeKind elem_kind;
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ lp_check_elem_type(union lp_type type, LLVMTypeRef elem_type)
|
|||
|
||||
|
||||
boolean
|
||||
lp_check_vec_type(union lp_type type, LLVMTypeRef vec_type)
|
||||
lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type)
|
||||
{
|
||||
LLVMTypeRef elem_type;
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ lp_check_vec_type(union lp_type type, LLVMTypeRef vec_type)
|
|||
|
||||
|
||||
boolean
|
||||
lp_check_value(union lp_type type, LLVMValueRef val)
|
||||
lp_check_value(struct lp_type type, LLVMValueRef val)
|
||||
{
|
||||
LLVMTypeRef vec_type;
|
||||
|
||||
|
|
@ -143,25 +143,26 @@ lp_check_value(union lp_type type, LLVMValueRef val)
|
|||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_int_elem_type(union lp_type type)
|
||||
lp_build_int_elem_type(struct lp_type type)
|
||||
{
|
||||
return LLVMIntType(type.width);
|
||||
}
|
||||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_int_vec_type(union lp_type type)
|
||||
lp_build_int_vec_type(struct lp_type type)
|
||||
{
|
||||
LLVMTypeRef elem_type = lp_build_int_elem_type(type);
|
||||
return LLVMVectorType(elem_type, type.length);
|
||||
}
|
||||
|
||||
|
||||
union lp_type
|
||||
lp_int_type(union lp_type type)
|
||||
struct lp_type
|
||||
lp_int_type(struct lp_type type)
|
||||
{
|
||||
union lp_type int_type;
|
||||
int_type.value = 0;
|
||||
struct lp_type int_type;
|
||||
|
||||
memset(&int_type, 0, sizeof int_type);
|
||||
int_type.width = type.width;
|
||||
int_type.length = type.length;
|
||||
return int_type;
|
||||
|
|
@ -171,7 +172,7 @@ lp_int_type(union lp_type type)
|
|||
void
|
||||
lp_build_context_init(struct lp_build_context *bld,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type)
|
||||
struct lp_type type)
|
||||
{
|
||||
bld->builder = builder;
|
||||
bld->type = type;
|
||||
|
|
|
|||
|
|
@ -56,58 +56,55 @@
|
|||
* on the types used for intermediate computations, such as signed vs unsigned,
|
||||
* normalized values, or fixed point.
|
||||
*/
|
||||
union lp_type {
|
||||
struct {
|
||||
/**
|
||||
* Floating-point. Cannot be used with fixed. Integer numbers are
|
||||
* represented by this zero.
|
||||
*/
|
||||
unsigned floating:1;
|
||||
struct lp_type {
|
||||
/**
|
||||
* Floating-point. Cannot be used with fixed. Integer numbers are
|
||||
* represented by this zero.
|
||||
*/
|
||||
unsigned floating:1;
|
||||
|
||||
/**
|
||||
* Fixed-point. Cannot be used with floating. Integer numbers are
|
||||
* represented by this zero.
|
||||
*/
|
||||
unsigned fixed:1;
|
||||
|
||||
/**
|
||||
* Whether it can represent negative values or not.
|
||||
*
|
||||
* If this is not set for floating point, it means that all values are
|
||||
* assumed to be positive.
|
||||
*/
|
||||
unsigned sign:1;
|
||||
/**
|
||||
* Fixed-point. Cannot be used with floating. Integer numbers are
|
||||
* represented by this zero.
|
||||
*/
|
||||
unsigned fixed:1;
|
||||
|
||||
/**
|
||||
* Whether values are normalized to fit [0, 1] interval, or [-1, 1]
|
||||
* interval for signed types.
|
||||
*
|
||||
* For integer types it means the representable integer range should be
|
||||
* interpreted as the interval above.
|
||||
*
|
||||
* For floating and fixed point formats it means the values should be
|
||||
* clamped to the interval above.
|
||||
*/
|
||||
unsigned norm:1;
|
||||
/**
|
||||
* Whether it can represent negative values or not.
|
||||
*
|
||||
* If this is not set for floating point, it means that all values are
|
||||
* assumed to be positive.
|
||||
*/
|
||||
unsigned sign:1;
|
||||
|
||||
/**
|
||||
* Element width.
|
||||
*
|
||||
* For fixed point values, the fixed point is assumed to be at half the
|
||||
* width.
|
||||
*/
|
||||
unsigned width:14;
|
||||
/**
|
||||
* Whether values are normalized to fit [0, 1] interval, or [-1, 1]
|
||||
* interval for signed types.
|
||||
*
|
||||
* For integer types it means the representable integer range should be
|
||||
* interpreted as the interval above.
|
||||
*
|
||||
* For floating and fixed point formats it means the values should be
|
||||
* clamped to the interval above.
|
||||
*/
|
||||
unsigned norm:1;
|
||||
|
||||
/**
|
||||
* Vector length.
|
||||
*
|
||||
* width*length should be a power of two greater or equal to eight.
|
||||
*
|
||||
* @sa LP_MAX_VECTOR_LENGTH
|
||||
*/
|
||||
unsigned length:14;
|
||||
};
|
||||
uint32_t value;
|
||||
/**
|
||||
* Element width.
|
||||
*
|
||||
* For fixed point values, the fixed point is assumed to be at half the
|
||||
* width.
|
||||
*/
|
||||
unsigned width:14;
|
||||
|
||||
/**
|
||||
* Vector length.
|
||||
*
|
||||
* width*length should be a power of two greater or equal to eight.
|
||||
*
|
||||
* @sa LP_MAX_VECTOR_LENGTH
|
||||
*/
|
||||
unsigned length:14;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -124,7 +121,7 @@ struct lp_build_context
|
|||
* This not only describes the input/output LLVM types, but also whether
|
||||
* to normalize/clamp the results.
|
||||
*/
|
||||
union lp_type type;
|
||||
struct lp_type type;
|
||||
|
||||
/** Same as lp_build_undef(type) */
|
||||
LLVMValueRef undef;
|
||||
|
|
@ -138,41 +135,41 @@ struct lp_build_context
|
|||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_elem_type(union lp_type type);
|
||||
lp_build_elem_type(struct lp_type type);
|
||||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_vec_type(union lp_type type);
|
||||
lp_build_vec_type(struct lp_type type);
|
||||
|
||||
|
||||
boolean
|
||||
lp_check_elem_type(union lp_type type, LLVMTypeRef elem_type);
|
||||
lp_check_elem_type(struct lp_type type, LLVMTypeRef elem_type);
|
||||
|
||||
|
||||
boolean
|
||||
lp_check_vec_type(union lp_type type, LLVMTypeRef vec_type);
|
||||
lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type);
|
||||
|
||||
|
||||
boolean
|
||||
lp_check_value(union lp_type type, LLVMValueRef val);
|
||||
lp_check_value(struct lp_type type, LLVMValueRef val);
|
||||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_int_elem_type(union lp_type type);
|
||||
lp_build_int_elem_type(struct lp_type type);
|
||||
|
||||
|
||||
LLVMTypeRef
|
||||
lp_build_int_vec_type(union lp_type type);
|
||||
lp_build_int_vec_type(struct lp_type type);
|
||||
|
||||
|
||||
union lp_type
|
||||
lp_int_type(union lp_type type);
|
||||
struct lp_type
|
||||
lp_int_type(struct lp_type type);
|
||||
|
||||
|
||||
void
|
||||
lp_build_context_init(struct lp_build_context *bld,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type);
|
||||
struct lp_type type);
|
||||
|
||||
|
||||
#endif /* !LP_BLD_TYPE_H */
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen)
|
|||
screen->provider = LLVMCreateModuleProviderForExistingModule(screen->module);
|
||||
|
||||
if (LLVMCreateJITCompiler(&screen->engine, screen->provider, 1, &error)) {
|
||||
fprintf(stderr, "%s\n", error);
|
||||
_debug_printf("%s\n", error);
|
||||
LLVMDisposeMessage(error);
|
||||
abort();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ llvmpipe_get_param(struct pipe_screen *screen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 1;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 0;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -133,13 +133,13 @@ generate_pos0(LLVMBuilderRef builder,
|
|||
static void
|
||||
generate_depth(LLVMBuilderRef builder,
|
||||
const struct lp_fragment_shader_variant_key *key,
|
||||
union lp_type src_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_build_mask_context *mask,
|
||||
LLVMValueRef src,
|
||||
LLVMValueRef dst_ptr)
|
||||
{
|
||||
const struct util_format_description *format_desc;
|
||||
union lp_type dst_type;
|
||||
struct lp_type dst_type;
|
||||
|
||||
if(!key->depth.enabled)
|
||||
return;
|
||||
|
|
@ -181,7 +181,7 @@ generate_fs(struct llvmpipe_context *lp,
|
|||
struct lp_fragment_shader *shader,
|
||||
const struct lp_fragment_shader_variant_key *key,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef context_ptr,
|
||||
unsigned i,
|
||||
const struct lp_build_interp_soa_context *interp,
|
||||
|
|
@ -299,7 +299,7 @@ generate_fs(struct llvmpipe_context *lp,
|
|||
static void
|
||||
generate_blend(const struct pipe_blend_state *blend,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
LLVMValueRef context_ptr,
|
||||
LLVMValueRef mask,
|
||||
LLVMValueRef *src,
|
||||
|
|
@ -364,8 +364,8 @@ generate_fragment(struct llvmpipe_context *lp,
|
|||
{
|
||||
struct llvmpipe_screen *screen = llvmpipe_screen(lp->pipe.screen);
|
||||
struct lp_fragment_shader_variant *variant;
|
||||
union lp_type fs_type;
|
||||
union lp_type blend_type;
|
||||
struct lp_type fs_type;
|
||||
struct lp_type blend_type;
|
||||
LLVMTypeRef fs_elem_type;
|
||||
LLVMTypeRef fs_vec_type;
|
||||
LLVMTypeRef fs_int_vec_type;
|
||||
|
|
@ -431,7 +431,7 @@ generate_fragment(struct llvmpipe_context *lp,
|
|||
/* TODO: actually pick these based on the fs and color buffer
|
||||
* characteristics. */
|
||||
|
||||
fs_type.value = 0;
|
||||
memset(&fs_type, 0, sizeof fs_type);
|
||||
fs_type.floating = TRUE; /* floating point values */
|
||||
fs_type.sign = TRUE; /* values are signed */
|
||||
fs_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
|
||||
|
|
@ -439,7 +439,7 @@ generate_fragment(struct llvmpipe_context *lp,
|
|||
fs_type.length = 4; /* 4 element per vector */
|
||||
num_fs = 4;
|
||||
|
||||
blend_type.value = 0;
|
||||
memset(&blend_type, 0, sizeof blend_type);
|
||||
blend_type.floating = FALSE; /* values are integers */
|
||||
blend_type.sign = FALSE; /* values are unsigned */
|
||||
blend_type.norm = TRUE; /* values are in [0,1] or [-1,1] */
|
||||
|
|
|
|||
|
|
@ -86,43 +86,43 @@ random_float(void);
|
|||
|
||||
|
||||
void
|
||||
dump_type(FILE *fp, union lp_type type);
|
||||
dump_type(FILE *fp, struct lp_type type);
|
||||
|
||||
|
||||
double
|
||||
read_elem(union lp_type type, const void *src, unsigned index);
|
||||
read_elem(struct lp_type type, const void *src, unsigned index);
|
||||
|
||||
|
||||
void
|
||||
write_elem(union lp_type type, void *dst, unsigned index, double src);
|
||||
write_elem(struct lp_type type, void *dst, unsigned index, double src);
|
||||
|
||||
|
||||
void
|
||||
random_elem(union lp_type type, void *dst, unsigned index);
|
||||
random_elem(struct lp_type type, void *dst, unsigned index);
|
||||
|
||||
|
||||
void
|
||||
read_vec(union lp_type type, const void *src, double *dst);
|
||||
read_vec(struct lp_type type, const void *src, double *dst);
|
||||
|
||||
|
||||
void
|
||||
write_vec(union lp_type type, void *dst, const double *src);
|
||||
write_vec(struct lp_type type, void *dst, const double *src);
|
||||
|
||||
|
||||
void
|
||||
random_vec(union lp_type type, void *dst);
|
||||
random_vec(struct lp_type type, void *dst);
|
||||
|
||||
|
||||
boolean
|
||||
compare_vec_with_eps(union lp_type type, const void *res, const void *ref, double eps);
|
||||
compare_vec_with_eps(struct lp_type type, const void *res, const void *ref, double eps);
|
||||
|
||||
|
||||
boolean
|
||||
compare_vec(union lp_type type, const void *res, const void *ref);
|
||||
compare_vec(struct lp_type type, const void *res, const void *ref);
|
||||
|
||||
|
||||
void
|
||||
dump_vec(FILE *fp, union lp_type type, const void *src);
|
||||
dump_vec(FILE *fp, struct lp_type type, const void *src);
|
||||
|
||||
|
||||
#endif /* !LP_TEST_H */
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ static void
|
|||
write_tsv_row(FILE *fp,
|
||||
const struct pipe_blend_state *blend,
|
||||
enum vector_mode mode,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
double cycles,
|
||||
boolean success)
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@ static void
|
|||
dump_blend_type(FILE *fp,
|
||||
const struct pipe_blend_state *blend,
|
||||
enum vector_mode mode,
|
||||
union lp_type type)
|
||||
struct lp_type type)
|
||||
{
|
||||
fprintf(fp, "%s", mode ? "soa" : "aos");
|
||||
|
||||
|
|
@ -153,7 +153,7 @@ static LLVMValueRef
|
|||
add_blend_test(LLVMModuleRef module,
|
||||
const struct pipe_blend_state *blend,
|
||||
enum vector_mode mode,
|
||||
union lp_type type)
|
||||
struct lp_type type)
|
||||
{
|
||||
LLVMTypeRef ret_type;
|
||||
LLVMTypeRef vec_type;
|
||||
|
|
@ -467,7 +467,7 @@ test_one(unsigned verbose,
|
|||
FILE *fp,
|
||||
const struct pipe_blend_state *blend,
|
||||
enum vector_mode mode,
|
||||
union lp_type type)
|
||||
struct lp_type type)
|
||||
{
|
||||
LLVMModuleRef module = NULL;
|
||||
LLVMValueRef func = NULL;
|
||||
|
|
@ -765,10 +765,10 @@ blend_funcs[] = {
|
|||
};
|
||||
|
||||
|
||||
const union lp_type blend_types[] = {
|
||||
const struct lp_type blend_types[] = {
|
||||
/* float, fixed, sign, norm, width, len */
|
||||
{{ TRUE, FALSE, FALSE, TRUE, 32, 4 }}, /* f32 x 4 */
|
||||
{{ FALSE, FALSE, FALSE, TRUE, 8, 16 }}, /* u8n x 16 */
|
||||
{ TRUE, FALSE, FALSE, TRUE, 32, 4 }, /* f32 x 4 */
|
||||
{ FALSE, FALSE, FALSE, TRUE, 8, 16 }, /* u8n x 16 */
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -788,7 +788,7 @@ test_all(unsigned verbose, FILE *fp)
|
|||
const unsigned *alpha_dst_factor;
|
||||
struct pipe_blend_state blend;
|
||||
enum vector_mode mode;
|
||||
const union lp_type *type;
|
||||
const struct lp_type *type;
|
||||
bool success = TRUE;
|
||||
|
||||
for(rgb_func = blend_funcs; rgb_func < &blend_funcs[num_funcs]; ++rgb_func) {
|
||||
|
|
@ -841,27 +841,27 @@ test_some(unsigned verbose, FILE *fp, unsigned long n)
|
|||
const unsigned *alpha_dst_factor;
|
||||
struct pipe_blend_state blend;
|
||||
enum vector_mode mode;
|
||||
const union lp_type *type;
|
||||
const struct lp_type *type;
|
||||
unsigned long i;
|
||||
bool success = TRUE;
|
||||
|
||||
for(i = 0; i < n; ++i) {
|
||||
rgb_func = &blend_funcs[random() % num_funcs];
|
||||
alpha_func = &blend_funcs[random() % num_funcs];
|
||||
rgb_src_factor = &blend_factors[random() % num_factors];
|
||||
alpha_src_factor = &blend_factors[random() % num_factors];
|
||||
rgb_func = &blend_funcs[rand() % num_funcs];
|
||||
alpha_func = &blend_funcs[rand() % num_funcs];
|
||||
rgb_src_factor = &blend_factors[rand() % num_factors];
|
||||
alpha_src_factor = &blend_factors[rand() % num_factors];
|
||||
|
||||
do {
|
||||
rgb_dst_factor = &blend_factors[random() % num_factors];
|
||||
rgb_dst_factor = &blend_factors[rand() % num_factors];
|
||||
} while(*rgb_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE);
|
||||
|
||||
do {
|
||||
alpha_dst_factor = &blend_factors[random() % num_factors];
|
||||
alpha_dst_factor = &blend_factors[rand() % num_factors];
|
||||
} while(*alpha_dst_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE);
|
||||
|
||||
mode = random() & 1;
|
||||
mode = rand() & 1;
|
||||
|
||||
type = &blend_types[random() % num_types];
|
||||
type = &blend_types[rand() % num_types];
|
||||
|
||||
memset(&blend, 0, sizeof blend);
|
||||
blend.blend_enable = 1;
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ write_tsv_header(FILE *fp)
|
|||
|
||||
static void
|
||||
write_tsv_row(FILE *fp,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type,
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type,
|
||||
double cycles,
|
||||
boolean success)
|
||||
{
|
||||
|
|
@ -80,8 +80,8 @@ write_tsv_row(FILE *fp,
|
|||
|
||||
static void
|
||||
dump_conv_types(FILE *fp,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type)
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type)
|
||||
{
|
||||
fprintf(fp, "src_type=");
|
||||
dump_type(fp, src_type);
|
||||
|
|
@ -96,8 +96,8 @@ dump_conv_types(FILE *fp,
|
|||
|
||||
static LLVMValueRef
|
||||
add_conv_test(LLVMModuleRef module,
|
||||
union lp_type src_type, unsigned num_srcs,
|
||||
union lp_type dst_type, unsigned num_dsts)
|
||||
struct lp_type src_type, unsigned num_srcs,
|
||||
struct lp_type dst_type, unsigned num_dsts)
|
||||
{
|
||||
LLVMTypeRef args[2];
|
||||
LLVMValueRef func;
|
||||
|
|
@ -145,8 +145,8 @@ add_conv_test(LLVMModuleRef module,
|
|||
static boolean
|
||||
test_one(unsigned verbose,
|
||||
FILE *fp,
|
||||
union lp_type src_type,
|
||||
union lp_type dst_type)
|
||||
struct lp_type src_type,
|
||||
struct lp_type dst_type)
|
||||
{
|
||||
LLVMModuleRef module = NULL;
|
||||
LLVMValueRef func = NULL;
|
||||
|
|
@ -343,35 +343,35 @@ test_one(unsigned verbose,
|
|||
}
|
||||
|
||||
|
||||
const union lp_type conv_types[] = {
|
||||
const struct lp_type conv_types[] = {
|
||||
/* float, fixed, sign, norm, width, len */
|
||||
|
||||
{{ TRUE, FALSE, TRUE, TRUE, 32, 4 }},
|
||||
{{ TRUE, FALSE, TRUE, FALSE, 32, 4 }},
|
||||
{{ TRUE, FALSE, FALSE, TRUE, 32, 4 }},
|
||||
{{ TRUE, FALSE, FALSE, FALSE, 32, 4 }},
|
||||
{ TRUE, FALSE, TRUE, TRUE, 32, 4 },
|
||||
{ TRUE, FALSE, TRUE, FALSE, 32, 4 },
|
||||
{ TRUE, FALSE, FALSE, TRUE, 32, 4 },
|
||||
{ TRUE, FALSE, FALSE, FALSE, 32, 4 },
|
||||
|
||||
/* TODO: test fixed formats too */
|
||||
|
||||
{{ FALSE, FALSE, TRUE, TRUE, 16, 8 }},
|
||||
{{ FALSE, FALSE, TRUE, FALSE, 16, 8 }},
|
||||
{{ FALSE, FALSE, FALSE, TRUE, 16, 8 }},
|
||||
{{ FALSE, FALSE, FALSE, FALSE, 16, 8 }},
|
||||
{ FALSE, FALSE, TRUE, TRUE, 16, 8 },
|
||||
{ FALSE, FALSE, TRUE, FALSE, 16, 8 },
|
||||
{ FALSE, FALSE, FALSE, TRUE, 16, 8 },
|
||||
{ FALSE, FALSE, FALSE, FALSE, 16, 8 },
|
||||
|
||||
{{ FALSE, FALSE, TRUE, TRUE, 32, 4 }},
|
||||
{{ FALSE, FALSE, TRUE, FALSE, 32, 4 }},
|
||||
{{ FALSE, FALSE, FALSE, TRUE, 32, 4 }},
|
||||
{{ FALSE, FALSE, FALSE, FALSE, 32, 4 }},
|
||||
{ FALSE, FALSE, TRUE, TRUE, 32, 4 },
|
||||
{ FALSE, FALSE, TRUE, FALSE, 32, 4 },
|
||||
{ FALSE, FALSE, FALSE, TRUE, 32, 4 },
|
||||
{ FALSE, FALSE, FALSE, FALSE, 32, 4 },
|
||||
|
||||
{{ FALSE, FALSE, TRUE, TRUE, 16, 8 }},
|
||||
{{ FALSE, FALSE, TRUE, FALSE, 16, 8 }},
|
||||
{{ FALSE, FALSE, FALSE, TRUE, 16, 8 }},
|
||||
{{ FALSE, FALSE, FALSE, FALSE, 16, 8 }},
|
||||
{ FALSE, FALSE, TRUE, TRUE, 16, 8 },
|
||||
{ FALSE, FALSE, TRUE, FALSE, 16, 8 },
|
||||
{ FALSE, FALSE, FALSE, TRUE, 16, 8 },
|
||||
{ FALSE, FALSE, FALSE, FALSE, 16, 8 },
|
||||
|
||||
{{ FALSE, FALSE, TRUE, TRUE, 8, 16 }},
|
||||
{{ FALSE, FALSE, TRUE, FALSE, 8, 16 }},
|
||||
{{ FALSE, FALSE, FALSE, TRUE, 8, 16 }},
|
||||
{{ FALSE, FALSE, FALSE, FALSE, 8, 16 }},
|
||||
{ FALSE, FALSE, TRUE, TRUE, 8, 16 },
|
||||
{ FALSE, FALSE, TRUE, FALSE, 8, 16 },
|
||||
{ FALSE, FALSE, FALSE, TRUE, 8, 16 },
|
||||
{ FALSE, FALSE, FALSE, FALSE, 8, 16 },
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -381,8 +381,8 @@ const unsigned num_types = sizeof(conv_types)/sizeof(conv_types[0]);
|
|||
boolean
|
||||
test_all(unsigned verbose, FILE *fp)
|
||||
{
|
||||
const union lp_type *src_type;
|
||||
const union lp_type *dst_type;
|
||||
const struct lp_type *src_type;
|
||||
const struct lp_type *dst_type;
|
||||
bool success = TRUE;
|
||||
|
||||
for(src_type = conv_types; src_type < &conv_types[num_types]; ++src_type) {
|
||||
|
|
@ -407,16 +407,16 @@ test_all(unsigned verbose, FILE *fp)
|
|||
boolean
|
||||
test_some(unsigned verbose, FILE *fp, unsigned long n)
|
||||
{
|
||||
const union lp_type *src_type;
|
||||
const union lp_type *dst_type;
|
||||
const struct lp_type *src_type;
|
||||
const struct lp_type *dst_type;
|
||||
unsigned long i;
|
||||
bool success = TRUE;
|
||||
|
||||
for(i = 0; i < n; ++i) {
|
||||
src_type = &conv_types[random() % num_types];
|
||||
src_type = &conv_types[rand() % num_types];
|
||||
|
||||
do {
|
||||
dst_type = &conv_types[random() % num_types];
|
||||
dst_type = &conv_types[rand() % num_types];
|
||||
} while (src_type == dst_type || src_type->norm != dst_type->norm);
|
||||
|
||||
if(!test_one(verbose, fp, *src_type, *dst_type))
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
void
|
||||
dump_type(FILE *fp,
|
||||
union lp_type type)
|
||||
struct lp_type type)
|
||||
{
|
||||
fprintf(fp, "%s%s%u%sx%u",
|
||||
type.sign ? (type.floating || type.fixed ? "" : "s") : "u",
|
||||
|
|
@ -52,7 +52,7 @@ dump_type(FILE *fp,
|
|||
|
||||
|
||||
double
|
||||
read_elem(union lp_type type, const void *src, unsigned index)
|
||||
read_elem(struct lp_type type, const void *src, unsigned index)
|
||||
{
|
||||
double scale = lp_const_scale(type);
|
||||
double value;
|
||||
|
|
@ -115,7 +115,7 @@ read_elem(union lp_type type, const void *src, unsigned index)
|
|||
|
||||
|
||||
void
|
||||
write_elem(union lp_type type, void *dst, unsigned index, double value)
|
||||
write_elem(struct lp_type type, void *dst, unsigned index, double value)
|
||||
{
|
||||
assert(index < type.length);
|
||||
if(!type.sign && value < 0.0)
|
||||
|
|
@ -184,11 +184,11 @@ write_elem(union lp_type type, void *dst, unsigned index, double value)
|
|||
|
||||
|
||||
void
|
||||
random_elem(union lp_type type, void *dst, unsigned index)
|
||||
random_elem(struct lp_type type, void *dst, unsigned index)
|
||||
{
|
||||
double value;
|
||||
assert(index < type.length);
|
||||
value = (double)random()/(double)RAND_MAX;
|
||||
value = (double)rand()/(double)RAND_MAX;
|
||||
if(!type.norm) {
|
||||
unsigned long long mask;
|
||||
if (type.floating)
|
||||
|
|
@ -199,17 +199,17 @@ random_elem(union lp_type type, void *dst, unsigned index)
|
|||
mask = ((unsigned long long)1 << (type.width - 1)) - 1;
|
||||
else
|
||||
mask = ((unsigned long long)1 << type.width) - 1;
|
||||
value += (double)(mask & random());
|
||||
value += (double)(mask & rand());
|
||||
}
|
||||
if(!type.sign)
|
||||
if(random() & 1)
|
||||
if(rand() & 1)
|
||||
value = -value;
|
||||
write_elem(type, dst, index, value);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
read_vec(union lp_type type, const void *src, double *dst)
|
||||
read_vec(struct lp_type type, const void *src, double *dst)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < type.length; ++i)
|
||||
|
|
@ -218,7 +218,7 @@ read_vec(union lp_type type, const void *src, double *dst)
|
|||
|
||||
|
||||
void
|
||||
write_vec(union lp_type type, void *dst, const double *src)
|
||||
write_vec(struct lp_type type, void *dst, const double *src)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < type.length; ++i)
|
||||
|
|
@ -229,12 +229,12 @@ write_vec(union lp_type type, void *dst, const double *src)
|
|||
float
|
||||
random_float(void)
|
||||
{
|
||||
return (float)((double)random()/(double)RAND_MAX);
|
||||
return (float)((double)rand()/(double)RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
random_vec(union lp_type type, void *dst)
|
||||
random_vec(struct lp_type type, void *dst)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < type.length; ++i)
|
||||
|
|
@ -243,7 +243,7 @@ random_vec(union lp_type type, void *dst)
|
|||
|
||||
|
||||
boolean
|
||||
compare_vec_with_eps(union lp_type type, const void *res, const void *ref, double eps)
|
||||
compare_vec_with_eps(struct lp_type type, const void *res, const void *ref, double eps)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < type.length; ++i) {
|
||||
|
|
@ -259,7 +259,7 @@ compare_vec_with_eps(union lp_type type, const void *res, const void *ref, doubl
|
|||
|
||||
|
||||
boolean
|
||||
compare_vec(union lp_type type, const void *res, const void *ref)
|
||||
compare_vec(struct lp_type type, const void *res, const void *ref)
|
||||
{
|
||||
double eps = lp_const_eps(type);
|
||||
return compare_vec_with_eps(type, res, ref, eps);
|
||||
|
|
@ -267,7 +267,7 @@ compare_vec(union lp_type type, const void *res, const void *ref)
|
|||
|
||||
|
||||
void
|
||||
dump_vec(FILE *fp, union lp_type type, const void *src)
|
||||
dump_vec(FILE *fp, struct lp_type type, const void *src)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < type.length; ++i) {
|
||||
|
|
|
|||
|
|
@ -1654,7 +1654,7 @@ lp_c_sampler_soa_destroy(struct lp_build_sampler_soa *sampler)
|
|||
static void
|
||||
lp_c_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *_sampler,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
unsigned unit,
|
||||
unsigned num_coords,
|
||||
const LLVMValueRef *coords,
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ lp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler)
|
|||
static void
|
||||
lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base,
|
||||
LLVMBuilderRef builder,
|
||||
union lp_type type,
|
||||
struct lp_type type,
|
||||
unsigned unit,
|
||||
unsigned num_coords,
|
||||
const LLVMValueRef *coords,
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@ nv04_screen_get_param(struct pipe_screen *screen, int param)
|
|||
return 0;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 0;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ nv10_screen_get_param(struct pipe_screen *screen, int param)
|
|||
return 0;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 1;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ nv20_screen_get_param(struct pipe_screen *screen, int param)
|
|||
return 0;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 1;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ nv30_screen_get_param(struct pipe_screen *pscreen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 1;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 1;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 1;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -37,11 +37,12 @@ nv50_flush(struct pipe_context *pipe, unsigned flags,
|
|||
|
||||
/* We need this in the ddx for reliable composite, not sure what we're
|
||||
* actually flushing. We generate all our own flushes with flags = 0. */
|
||||
WAIT_RING(chan, 3);
|
||||
WAIT_RING(chan, 2);
|
||||
BEGIN_RING(chan, eng2d, 0x0110, 1);
|
||||
OUT_RING (chan, 0);
|
||||
|
||||
FIRE_RING(chan);
|
||||
if (flags & PIPE_FLUSH_FRAME)
|
||||
FIRE_RING(chan);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -110,6 +111,9 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
|
|||
nv50->pipe.is_texture_referenced = nv50_is_texture_referenced;
|
||||
nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced;
|
||||
|
||||
screen->base.channel->user_private = nv50;
|
||||
screen->base.channel->flush_notify = nv50_state_flush_notify;
|
||||
|
||||
nv50_init_surface_functions(nv50);
|
||||
nv50_init_state_functions(nv50);
|
||||
nv50_init_query_functions(nv50);
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ struct nv50_state {
|
|||
unsigned miptree_nr;
|
||||
struct nouveau_stateobj *vertprog;
|
||||
struct nouveau_stateobj *fragprog;
|
||||
struct nouveau_stateobj *programs;
|
||||
struct nouveau_stateobj *vtxfmt;
|
||||
struct nouveau_stateobj *vtxbuf;
|
||||
struct nouveau_stateobj *vtxattr;
|
||||
|
|
@ -190,10 +191,12 @@ extern void nv50_clear(struct pipe_context *pipe, unsigned buffers,
|
|||
/* nv50_program.c */
|
||||
extern void nv50_vertprog_validate(struct nv50_context *nv50);
|
||||
extern void nv50_fragprog_validate(struct nv50_context *nv50);
|
||||
extern void nv50_linkage_validate(struct nv50_context *nv50);
|
||||
extern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p);
|
||||
|
||||
/* nv50_state_validate.c */
|
||||
extern boolean nv50_state_validate(struct nv50_context *nv50);
|
||||
extern void nv50_state_flush_notify(struct nouveau_channel *chan);
|
||||
|
||||
/* nv50_tex.c */
|
||||
extern void nv50_tex_validate(struct nv50_context *);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -15,6 +15,15 @@ struct nv50_program_exec {
|
|||
} param;
|
||||
};
|
||||
|
||||
struct nv50_sreg4 {
|
||||
uint8_t hw;
|
||||
uint8_t id_vp;
|
||||
uint8_t id_fp;
|
||||
|
||||
uint8_t mask;
|
||||
boolean linear;
|
||||
};
|
||||
|
||||
struct nv50_program {
|
||||
struct pipe_shader_state pipe;
|
||||
struct tgsi_shader_info info;
|
||||
|
|
@ -24,8 +33,8 @@ struct nv50_program {
|
|||
struct nv50_program_exec *exec_head;
|
||||
struct nv50_program_exec *exec_tail;
|
||||
unsigned exec_size;
|
||||
struct nouveau_resource *data[2];
|
||||
unsigned data_start[2];
|
||||
struct nouveau_resource *data[1];
|
||||
unsigned data_start[1];
|
||||
|
||||
struct nouveau_bo *bo;
|
||||
|
||||
|
|
@ -36,14 +45,20 @@ struct nv50_program {
|
|||
struct {
|
||||
unsigned high_temp;
|
||||
unsigned high_result;
|
||||
struct {
|
||||
unsigned attr[2];
|
||||
} vp;
|
||||
struct {
|
||||
unsigned regs[4];
|
||||
unsigned map[5];
|
||||
unsigned high_map;
|
||||
} fp;
|
||||
|
||||
uint32_t attr[2];
|
||||
uint32_t regs[4];
|
||||
|
||||
/* for VPs, io_nr doesn't count 'private' results (PSIZ etc.) */
|
||||
unsigned io_nr;
|
||||
struct nv50_sreg4 io[PIPE_MAX_SHADER_OUTPUTS];
|
||||
|
||||
/* FP colour inputs, VP/GP back colour outputs */
|
||||
struct nv50_sreg4 two_side[2];
|
||||
|
||||
/* VP only */
|
||||
uint8_t clpd, clpd_nr;
|
||||
uint8_t psiz;
|
||||
} cfg;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -87,12 +87,10 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 0;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 1;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 1;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
return 0;
|
||||
return 1;
|
||||
case PIPE_CAP_MAX_RENDER_TARGETS:
|
||||
return 8;
|
||||
case PIPE_CAP_OCCLUSION_QUERY:
|
||||
|
|
|
|||
|
|
@ -276,6 +276,9 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
|
|||
so_method(so, tesla, 0x1684, 1);
|
||||
so_data (so, cso->flatshade_first ? 0 : 1);
|
||||
|
||||
so_method(so, tesla, NV50TCL_VERTEX_TWO_SIDE_ENABLE, 1);
|
||||
so_data (so, cso->light_twoside);
|
||||
|
||||
so_method(so, tesla, NV50TCL_LINE_WIDTH, 1);
|
||||
so_data (so, fui(cso->line_width));
|
||||
so_method(so, tesla, NV50TCL_LINE_SMOOTH_ENABLE, 1);
|
||||
|
|
@ -294,6 +297,9 @@ nv50_rasterizer_state_create(struct pipe_context *pipe,
|
|||
so_method(so, tesla, NV50TCL_POINT_SIZE, 1);
|
||||
so_data (so, fui(cso->point_size));
|
||||
|
||||
so_method(so, tesla, NV50TCL_POINT_SPRITE_ENABLE, 1);
|
||||
so_data (so, cso->point_sprite);
|
||||
|
||||
so_method(so, tesla, NV50TCL_POLYGON_MODE_FRONT, 3);
|
||||
if (cso->front_winding == PIPE_WINDING_CCW) {
|
||||
so_data(so, nvgl_polygon_mode(cso->fill_ccw));
|
||||
|
|
|
|||
|
|
@ -189,6 +189,8 @@ nv50_state_emit(struct nv50_context *nv50)
|
|||
so_emit(chan, nv50->state.vertprog);
|
||||
if (nv50->state.dirty & NV50_NEW_FRAGPROG)
|
||||
so_emit(chan, nv50->state.fragprog);
|
||||
if (nv50->state.dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG))
|
||||
so_emit(chan, nv50->state.programs);
|
||||
if (nv50->state.dirty & NV50_NEW_RASTERIZER)
|
||||
so_emit(chan, nv50->state.rast);
|
||||
if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR)
|
||||
|
|
@ -210,6 +212,12 @@ nv50_state_emit(struct nv50_context *nv50)
|
|||
so_emit(chan, nv50->state.vtxattr);
|
||||
}
|
||||
nv50->state.dirty = 0;
|
||||
}
|
||||
|
||||
void
|
||||
nv50_state_flush_notify(struct nouveau_channel *chan)
|
||||
{
|
||||
struct nv50_context *nv50 = chan->user_private;
|
||||
|
||||
so_emit_reloc_markers(chan, nv50->state.fb);
|
||||
so_emit_reloc_markers(chan, nv50->state.vertprog);
|
||||
|
|
@ -240,6 +248,9 @@ nv50_state_validate(struct nv50_context *nv50)
|
|||
if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_FRAGPROG_CB))
|
||||
nv50_fragprog_validate(nv50);
|
||||
|
||||
if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG))
|
||||
nv50_linkage_validate(nv50);
|
||||
|
||||
if (nv50->dirty & NV50_NEW_RASTERIZER)
|
||||
so_ref(nv50->rasterizer->so, &nv50->state.rast);
|
||||
|
||||
|
|
|
|||
|
|
@ -89,14 +89,14 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
|
|||
if (src_bo->tile_flags) {
|
||||
BEGIN_RING(chan, m2mf,
|
||||
NV50_MEMORY_TO_MEMORY_FORMAT_TILING_POSITION_IN, 1);
|
||||
OUT_RING (chan, (sy << 16) | sx);
|
||||
OUT_RING (chan, (sy << 16) | (sx * cpp));
|
||||
} else {
|
||||
src_offset += (line_count * src_pitch);
|
||||
}
|
||||
if (dst_bo->tile_flags) {
|
||||
BEGIN_RING(chan, m2mf,
|
||||
NV50_MEMORY_TO_MEMORY_FORMAT_TILING_POSITION_OUT, 1);
|
||||
OUT_RING (chan, (dy << 16) | dx);
|
||||
OUT_RING (chan, (dy << 16) | (dx * cpp));
|
||||
} else {
|
||||
dst_offset += (line_count * dst_pitch);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ static int r300_get_param(struct pipe_screen* pscreen, int param)
|
|||
} else {
|
||||
return 0;
|
||||
}
|
||||
case PIPE_CAP_S3TC:
|
||||
return 1;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 1;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
|
|||
|
|
@ -65,8 +65,6 @@ softpipe_get_param(struct pipe_screen *screen, int param)
|
|||
return 1;
|
||||
case PIPE_CAP_GLSL:
|
||||
return 1;
|
||||
case PIPE_CAP_S3TC:
|
||||
return 0;
|
||||
case PIPE_CAP_ANISOTROPIC_FILTER:
|
||||
return 0;
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
|
|
@ -141,6 +139,7 @@ softpipe_is_format_supported( struct pipe_screen *screen,
|
|||
case PIPE_FORMAT_DXT1_RGBA:
|
||||
case PIPE_FORMAT_DXT3_RGBA:
|
||||
case PIPE_FORMAT_DXT5_RGBA:
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
return FALSE;
|
||||
default:
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ enum pipe_transfer_usage {
|
|||
#define PIPE_CAP_NPOT_TEXTURES 2
|
||||
#define PIPE_CAP_TWO_SIDED_STENCIL 3
|
||||
#define PIPE_CAP_GLSL 4 /* XXX need something better */
|
||||
#define PIPE_CAP_S3TC 5
|
||||
#define PIPE_CAP_S3TC 5 /* XXX: deprecated; cap determined via supported sampler formats */
|
||||
#define PIPE_CAP_ANISOTROPIC_FILTER 6
|
||||
#define PIPE_CAP_POINT_SPRITE 7
|
||||
#define PIPE_CAP_MAX_RENDER_TARGETS 8
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ pipe_buffer_write(struct pipe_screen *screen,
|
|||
unsigned offset, unsigned size,
|
||||
const void *data)
|
||||
{
|
||||
uint8_t *map;
|
||||
void *map;
|
||||
|
||||
assert(offset < buf->size);
|
||||
assert(offset + size <= buf->size);
|
||||
|
|
@ -129,7 +129,7 @@ pipe_buffer_write(struct pipe_screen *screen,
|
|||
PIPE_BUFFER_USAGE_FLUSH_EXPLICIT);
|
||||
assert(map);
|
||||
if(map) {
|
||||
memcpy(map + offset, data, size);
|
||||
memcpy((uint8_t *)map + offset, data, size);
|
||||
pipe_buffer_flush_mapped_range(screen, buf, offset, size);
|
||||
pipe_buffer_unmap(screen, buf);
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ pipe_buffer_read(struct pipe_screen *screen,
|
|||
unsigned offset, unsigned size,
|
||||
void *data)
|
||||
{
|
||||
uint8_t *map;
|
||||
void *map;
|
||||
|
||||
assert(offset < buf->size);
|
||||
assert(offset + size <= buf->size);
|
||||
|
|
@ -150,11 +150,31 @@ pipe_buffer_read(struct pipe_screen *screen,
|
|||
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
|
||||
assert(map);
|
||||
if(map) {
|
||||
memcpy(data, map + offset, size);
|
||||
memcpy(data, (const uint8_t *)map + offset, size);
|
||||
pipe_buffer_unmap(screen, buf);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void *
|
||||
pipe_transfer_map( struct pipe_transfer *transf )
|
||||
{
|
||||
struct pipe_screen *screen = transf->texture->screen;
|
||||
return screen->transfer_map(screen, transf);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
pipe_transfer_unmap( struct pipe_transfer *transf )
|
||||
{
|
||||
struct pipe_screen *screen = transf->texture->screen;
|
||||
screen->transfer_unmap(screen, transf);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
pipe_transfer_destroy( struct pipe_transfer *transf )
|
||||
{
|
||||
struct pipe_screen *screen = transf->texture->screen;
|
||||
screen->tex_transfer_destroy(transf);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ struct pipe_transfer
|
|||
unsigned nblocksx; /**< allocated width in blocks */
|
||||
unsigned nblocksy; /**< allocated height in blocks */
|
||||
unsigned stride; /**< stride in bytes between rows of blocks */
|
||||
unsigned usage; /**< PIPE_TRANSFER_* */
|
||||
enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */
|
||||
|
||||
struct pipe_texture *texture; /**< texture to transfer to/from */
|
||||
unsigned face;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "util/u_debug.h" /* for assert */
|
||||
|
||||
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
|
||||
#include <pthread.h> /* POSIX threads headers */
|
||||
#include <stdio.h> /* for perror() */
|
||||
|
|
@ -213,7 +213,7 @@ typedef unsigned pipe_condvar;
|
|||
*/
|
||||
|
||||
typedef struct {
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
pthread_key_t key;
|
||||
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
|
||||
DWORD key;
|
||||
|
|
@ -228,7 +228,7 @@ typedef struct {
|
|||
static INLINE void
|
||||
pipe_tsd_init(pipe_tsd *tsd)
|
||||
{
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
|
||||
perror("pthread_key_create(): failed to allocate key for thread specific data");
|
||||
exit(-1);
|
||||
|
|
@ -245,7 +245,7 @@ pipe_tsd_get(pipe_tsd *tsd)
|
|||
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
|
||||
pipe_tsd_init(tsd);
|
||||
}
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
return pthread_getspecific(tsd->key);
|
||||
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
|
||||
assert(0);
|
||||
|
|
@ -262,7 +262,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
|
|||
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
|
||||
pipe_tsd_init(tsd);
|
||||
}
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
if (pthread_setspecific(tsd->key, value) != 0) {
|
||||
perror("pthread_set_specific() failed");
|
||||
exit(-1);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ static int vlResizeFrameBuffer
|
|||
struct vlBasicCSC *basic_csc;
|
||||
struct pipe_context *pipe;
|
||||
struct pipe_texture template;
|
||||
float clear_color[4];
|
||||
|
||||
assert(csc);
|
||||
|
||||
|
|
@ -68,7 +69,12 @@ static int vlResizeFrameBuffer
|
|||
basic_csc->viewport.translate[1] = 0;
|
||||
basic_csc->viewport.translate[2] = 0;
|
||||
basic_csc->viewport.translate[3] = 0;
|
||||
|
||||
|
||||
clear_color[0] = 0.0f;
|
||||
clear_color[1] = 0.0f;
|
||||
clear_color[2] = 0.0f;
|
||||
clear_color[3] = 0.0f;
|
||||
|
||||
if (basic_csc->framebuffer_tex)
|
||||
{
|
||||
pipe_surface_reference(&basic_csc->framebuffer.cbufs[0], NULL);
|
||||
|
|
@ -98,7 +104,7 @@ static int vlResizeFrameBuffer
|
|||
|
||||
/* Clear to black, in case video doesn't fill the entire window */
|
||||
pipe->set_framebuffer_state(pipe, &basic_csc->framebuffer);
|
||||
pipe->clear(pipe, PIPE_CLEAR_COLOR, 0, 0.0f, 0);
|
||||
pipe->clear(pipe, PIPE_CLEAR_COLOR, clear_color, 0.0f, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@ struct xorg_composite_blend {
|
|||
int op:8;
|
||||
|
||||
unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */
|
||||
unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
|
||||
|
||||
unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */
|
||||
|
||||
unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
|
||||
unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
|
||||
};
|
||||
|
||||
|
|
@ -653,17 +653,12 @@ boolean xorg_solid_bind_state(struct exa_context *exa,
|
|||
|
||||
exa->solid_color[3] = 1.f;
|
||||
|
||||
#if 0
|
||||
debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n",
|
||||
(fg >> 24) & 0xff, (fg >> 16) & 0xff,
|
||||
(fg >> 8) & 0xff, (fg >> 0) & 0xff,
|
||||
exa->solid_color[0], exa->solid_color[1],
|
||||
exa->solid_color[2], exa->solid_color[3]);
|
||||
|
||||
#if 0
|
||||
exa->solid_color[0] = 1.f;
|
||||
exa->solid_color[1] = 0.f;
|
||||
exa->solid_color[2] = 0.f;
|
||||
exa->solid_color[3] = 1.f;
|
||||
#endif
|
||||
|
||||
vs_traits = VS_SOLID_FILL;
|
||||
|
|
@ -691,9 +686,6 @@ void xorg_solid(struct exa_context *exa,
|
|||
struct pipe_buffer *buf = 0;
|
||||
float vertices[4][2][4];
|
||||
|
||||
x0 = 10; y0 = 10;
|
||||
x1 = 300; y1 = 300;
|
||||
|
||||
/* 1st vertex */
|
||||
setup_vertex0(vertices[0], x0, y0,
|
||||
exa->solid_color);
|
||||
|
|
@ -844,11 +836,6 @@ static void renderer_copy_texture(struct exa_context *exa,
|
|||
assert(dst->width[0] != 0);
|
||||
assert(dst->height[0] != 0);
|
||||
|
||||
#if 0
|
||||
debug_printf("copy texture [%f, %f, %f, %f], [%f, %f, %f, %f]\n",
|
||||
sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
s0 = sx1 / src->width[0];
|
||||
s1 = sx2 / src->width[0];
|
||||
|
|
@ -861,8 +848,16 @@ static void renderer_copy_texture(struct exa_context *exa,
|
|||
t1 = 1;
|
||||
#endif
|
||||
|
||||
assert(screen->is_format_supported(screen, dst_surf->format, PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
|
||||
#if 1
|
||||
debug_printf("copy texture src=[%f, %f, %f, %f], dst=[%f, %f, %f, %f], tex=[%f, %f, %f, %f]\n",
|
||||
sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2,
|
||||
s0, t0, s1, t1);
|
||||
#endif
|
||||
|
||||
assert(screen->is_format_supported(screen, dst_surf->format,
|
||||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET,
|
||||
0));
|
||||
|
||||
/* save state (restored below) */
|
||||
cso_save_blend(exa->cso);
|
||||
|
|
@ -926,6 +921,8 @@ static void renderer_copy_texture(struct exa_context *exa,
|
|||
fb.cbufs[i] = 0;
|
||||
}
|
||||
cso_set_framebuffer(exa->cso, &fb);
|
||||
setup_vs_constant_buffer(exa, fb.width, fb.height);
|
||||
setup_fs_constant_buffer(exa);
|
||||
|
||||
/* draw quad */
|
||||
buf = setup_vertex_data_tex(exa,
|
||||
|
|
@ -955,6 +952,61 @@ static void renderer_copy_texture(struct exa_context *exa,
|
|||
pipe_surface_reference(&dst_surf, NULL);
|
||||
}
|
||||
|
||||
|
||||
static struct pipe_texture *
|
||||
create_sampler_texture(struct exa_context *ctx,
|
||||
struct pipe_texture *src)
|
||||
{
|
||||
enum pipe_format format;
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
struct pipe_texture *pt;
|
||||
struct pipe_texture templ;
|
||||
|
||||
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
|
||||
|
||||
/* the coming in texture should already have that invariance */
|
||||
debug_assert(screen->is_format_supported(screen, src->format,
|
||||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_SAMPLER, 0));
|
||||
|
||||
format = src->format;
|
||||
|
||||
memset(&templ, 0, sizeof(templ));
|
||||
templ.target = PIPE_TEXTURE_2D;
|
||||
templ.format = format;
|
||||
templ.last_level = 0;
|
||||
templ.width[0] = src->width[0];
|
||||
templ.height[0] = src->height[0];
|
||||
templ.depth[0] = 1;
|
||||
pf_get_block(format, &templ.block);
|
||||
templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
|
||||
|
||||
pt = screen->texture_create(screen, &templ);
|
||||
|
||||
debug_assert(!pt || pipe_is_referenced(&pt->reference));
|
||||
|
||||
if (!pt)
|
||||
return NULL;
|
||||
|
||||
{
|
||||
/* copy source framebuffer surface into texture */
|
||||
struct pipe_surface *ps_read = screen->get_tex_surface(
|
||||
screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
|
||||
struct pipe_surface *ps_tex = screen->get_tex_surface(
|
||||
screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE );
|
||||
pipe->surface_copy(pipe,
|
||||
ps_tex, /* dest */
|
||||
0, 0, /* destx/y */
|
||||
ps_read,
|
||||
0, 0, src->width[0], src->height[0]);
|
||||
pipe_surface_reference(&ps_read, NULL);
|
||||
pipe_surface_reference(&ps_tex, NULL);
|
||||
}
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
void xorg_copy_pixmap(struct exa_context *ctx,
|
||||
struct exa_pixmap_priv *dst_priv, int dx, int dy,
|
||||
struct exa_pixmap_priv *src_priv, int sx, int sy,
|
||||
|
|
@ -966,6 +1018,8 @@ void xorg_copy_pixmap(struct exa_context *ctx,
|
|||
struct pipe_texture *dst = dst_priv->tex;
|
||||
struct pipe_texture *src = src_priv->tex;
|
||||
|
||||
xorg_exa_finish(ctx);
|
||||
|
||||
dst_loc[0] = dx;
|
||||
dst_loc[1] = dy;
|
||||
dst_loc[2] = width;
|
||||
|
|
@ -1003,17 +1057,25 @@ void xorg_copy_pixmap(struct exa_context *ctx,
|
|||
|
||||
if (src_loc[2] >= 0 && src_loc[3] >= 0 &&
|
||||
dst_loc[2] >= 0 && dst_loc[3] >= 0) {
|
||||
struct pipe_texture *temp_src = src;
|
||||
|
||||
if (src == dst)
|
||||
temp_src = create_sampler_texture(ctx, src);
|
||||
|
||||
renderer_copy_texture(ctx,
|
||||
src,
|
||||
temp_src,
|
||||
src_loc[0],
|
||||
src_loc[1] + src_loc[3],
|
||||
src_loc[0] + src_loc[2],
|
||||
src_loc[1],
|
||||
src_loc[0] + src_loc[2],
|
||||
src_loc[1] + src_loc[3],
|
||||
dst,
|
||||
dst_loc[0],
|
||||
dst_loc[1] + dst_loc[3],
|
||||
dst_loc[1],
|
||||
dst_loc[0] + dst_loc[2],
|
||||
dst_loc[1]);
|
||||
dst_loc[1] + dst_loc[3]);
|
||||
|
||||
if (src == dst)
|
||||
pipe_texture_reference(&temp_src, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@
|
|||
|
||||
#include "util/u_rect.h"
|
||||
|
||||
#define DEBUG_SOLID 0
|
||||
|
||||
/*
|
||||
* Helper functions
|
||||
*/
|
||||
|
|
@ -72,6 +74,9 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp)
|
|||
assert(*bbp == 16);
|
||||
break;
|
||||
case 8:
|
||||
*format = PIPE_FORMAT_A8_UNORM;
|
||||
assert(*bbp == 8);
|
||||
break;
|
||||
case 4:
|
||||
case 1:
|
||||
*format = PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */
|
||||
|
|
@ -253,7 +258,7 @@ ExaDone(PixmapPtr pPixmap)
|
|||
#if 1
|
||||
xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
|
||||
#else
|
||||
xorg_finish(exa);
|
||||
xorg_exa_finish(exa);
|
||||
#endif
|
||||
xorg_exa_common_done(exa);
|
||||
}
|
||||
|
|
@ -276,23 +281,35 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
|
|||
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
|
||||
struct exa_context *exa = ms->exa;
|
||||
|
||||
#if 0
|
||||
debug_printf("ExaPrepareSolid - test\n");
|
||||
if (pPixmap->drawable.depth < 15)
|
||||
return FALSE;
|
||||
|
||||
#endif
|
||||
if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask))
|
||||
return FALSE;
|
||||
|
||||
if (!priv || !priv->tex)
|
||||
return FALSE;
|
||||
|
||||
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
|
||||
priv->tex->target,
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
|
||||
return FALSE;
|
||||
|
||||
if (alu != GXcopy)
|
||||
return FALSE;
|
||||
|
||||
if (!exa->pipe)
|
||||
return FALSE;
|
||||
|
||||
|
||||
#if DEBUG_SOLID
|
||||
fg = 0xffff0000;
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
debug_printf(" ExaPrepareSolid(0x%x)\n", fg);
|
||||
#endif
|
||||
|
||||
return xorg_solid_bind_state(exa, priv, fg);
|
||||
}
|
||||
|
||||
|
|
@ -310,11 +327,42 @@ ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1)
|
|||
if (x0 == 0 && y0 == 0 &&
|
||||
x1 == priv->tex->width[0] &&
|
||||
y1 == priv->tex->height[0]) {
|
||||
exa->ctx->clear(exa->ctx, PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL,
|
||||
exa->ctx->clear(exa->pipe, PIPE_CLEAR_COLOR,
|
||||
exa->solid_color, 1., 0);
|
||||
} else
|
||||
#endif
|
||||
xorg_solid(exa, priv, x0, y0, x1, y1) ;
|
||||
|
||||
#if DEBUG_SOLID
|
||||
exa->solid_color[0] = 0.f;
|
||||
exa->solid_color[1] = 1.f;
|
||||
exa->solid_color[2] = 0.f;
|
||||
exa->solid_color[3] = 1.f;
|
||||
xorg_solid(exa, priv, 0, 0, 1024, 768);
|
||||
exa->solid_color[0] = 1.f;
|
||||
exa->solid_color[1] = 0.f;
|
||||
exa->solid_color[2] = 0.f;
|
||||
exa->solid_color[3] = 1.f;
|
||||
xorg_solid(exa, priv, 0, 0, 300, 300);
|
||||
xorg_solid(exa, priv, 300, 300, 350, 350);
|
||||
xorg_solid(exa, priv, 350, 350, 500, 500);
|
||||
|
||||
xorg_solid(exa, priv,
|
||||
priv->tex->width[0] - 10,
|
||||
priv->tex->height[0] - 10,
|
||||
priv->tex->width[0],
|
||||
priv->tex->height[0]);
|
||||
|
||||
exa->solid_color[0] = 0.f;
|
||||
exa->solid_color[1] = 0.f;
|
||||
exa->solid_color[2] = 1.f;
|
||||
exa->solid_color[3] = 1.f;
|
||||
|
||||
exa->has_solid_color = FALSE;
|
||||
ExaPrepareCopy(pPixmap, pPixmap, 0, 0, GXcopy, 0xffffffff);
|
||||
ExaCopy(pPixmap, 0, 0, 50, 50, 500, 500);
|
||||
#else
|
||||
xorg_solid(exa, priv, x0, y0, x1, y1) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
static Bool
|
||||
|
|
@ -332,15 +380,20 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
|
|||
if (alu != GXcopy)
|
||||
return FALSE;
|
||||
|
||||
if (pSrcPixmap->drawable.depth < 15 || pDstPixmap->drawable.depth < 15)
|
||||
return FALSE;
|
||||
|
||||
if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask))
|
||||
return FALSE;
|
||||
|
||||
if (!priv || !src_priv)
|
||||
return FALSE;
|
||||
|
||||
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
|
||||
priv->tex->target,
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0) ||
|
||||
!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format,
|
||||
src_priv->tex->target,
|
||||
PIPE_TEXTURE_USAGE_SAMPLER, 0))
|
||||
return FALSE;
|
||||
|
||||
if (!priv->tex || !src_priv->tex)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -433,14 +486,11 @@ static void
|
|||
ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv)
|
||||
{
|
||||
struct exa_pixmap_priv *priv = (struct exa_pixmap_priv *)dPriv;
|
||||
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
|
||||
modesettingPtr ms = modesettingPTR(pScrn);
|
||||
|
||||
if (!priv)
|
||||
return;
|
||||
|
||||
if (priv->tex)
|
||||
ms->screen->texture_destroy(priv->tex);
|
||||
pipe_texture_reference(&priv->tex, NULL);
|
||||
|
||||
xfree(priv);
|
||||
}
|
||||
|
|
@ -583,8 +633,8 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
|
|||
struct pipe_surface *dst_surf;
|
||||
struct pipe_surface *src_surf;
|
||||
|
||||
dst_surf = exa->scrn->get_tex_surface(exa->scrn, texture, 0, 0, 0,
|
||||
PIPE_BUFFER_USAGE_GPU_WRITE);
|
||||
dst_surf = exa->scrn->get_tex_surface(
|
||||
exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
|
||||
src_surf = exa_gpu_surface(exa, priv);
|
||||
exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
|
||||
0, 0, min(width, texture->width[0]),
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ struct xorg_shaders {
|
|||
|
||||
static const char over_op[] =
|
||||
"SUB TEMP[3], CONST[0].wwww, TEMP[1].wwww\n"
|
||||
"MUL TEMP[3], TEMP[0], TEMP[3]\n"
|
||||
"ADD TEMP[0], TEMP[3], TEMP[0]\n";
|
||||
"MAD TEMP[3], TEMP[0], TEMP[3], TEMP[0]\n";
|
||||
|
||||
|
||||
static INLINE void
|
||||
|
|
@ -79,8 +78,7 @@ vs_normalize_coords(struct ureg_program *ureg, struct ureg_src coords,
|
|||
{
|
||||
struct ureg_dst tmp = ureg_DECL_temporary(ureg);
|
||||
struct ureg_src ret;
|
||||
ureg_MUL(ureg, tmp, coords, const0);
|
||||
ureg_ADD(ureg, tmp, ureg_src(tmp), const1);
|
||||
ureg_MAD(ureg, tmp, coords, const0, const1);
|
||||
ret = ureg_src(tmp);
|
||||
ureg_release_temporary(ureg, tmp);
|
||||
return ret;
|
||||
|
|
@ -261,7 +259,7 @@ create_vs(struct pipe_context *pipe,
|
|||
|
||||
if (is_composite) {
|
||||
src = ureg_DECL_vs_input(ureg, input_slot++);
|
||||
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1);
|
||||
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0);
|
||||
ureg_MOV(ureg, dst, src);
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +310,7 @@ create_fs(struct pipe_context *pipe,
|
|||
if (is_composite) {
|
||||
src_sampler = ureg_DECL_sampler(ureg, 0);
|
||||
src_input = ureg_DECL_fs_input(ureg,
|
||||
TGSI_SEMANTIC_POSITION,
|
||||
TGSI_SEMANTIC_GENERIC,
|
||||
0,
|
||||
TGSI_INTERPOLATE_PERSPECTIVE);
|
||||
} else {
|
||||
|
|
@ -367,11 +365,11 @@ create_fs(struct pipe_context *pipe,
|
|||
else
|
||||
src = out;
|
||||
|
||||
coords = ureg_DECL_constant(ureg);
|
||||
const0124 = ureg_DECL_constant(ureg);
|
||||
matrow0 = ureg_DECL_constant(ureg);
|
||||
matrow1 = ureg_DECL_constant(ureg);
|
||||
matrow2 = ureg_DECL_constant(ureg);
|
||||
coords = ureg_DECL_constant(ureg, 0);
|
||||
const0124 = ureg_DECL_constant(ureg, 1);
|
||||
matrow0 = ureg_DECL_constant(ureg, 2);
|
||||
matrow1 = ureg_DECL_constant(ureg, 3);
|
||||
matrow2 = ureg_DECL_constant(ureg, 4);
|
||||
|
||||
if (is_lingrad) {
|
||||
linear_gradient(ureg, src,
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ static struct pipe_buffer* xsp_surface_buffer_create
|
|||
unsigned height,
|
||||
enum pipe_format format,
|
||||
unsigned usage,
|
||||
unsigned tex_usage,
|
||||
unsigned *stride
|
||||
)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,35 +5,39 @@ Import('*')
|
|||
|
||||
if env['platform'] == 'windows':
|
||||
|
||||
env = env.Clone()
|
||||
env = env.Clone()
|
||||
|
||||
env.Append(CPPPATH = [
|
||||
'#src/gallium/state_trackers/wgl',
|
||||
])
|
||||
env.Append(CPPPATH = [
|
||||
'#src/gallium/state_trackers/wgl',
|
||||
])
|
||||
|
||||
env.Append(LIBS = [
|
||||
'gdi32',
|
||||
'user32',
|
||||
'kernel32',
|
||||
'ws2_32',
|
||||
])
|
||||
env.Append(LIBS = [
|
||||
'gdi32',
|
||||
'user32',
|
||||
'kernel32',
|
||||
'ws2_32',
|
||||
])
|
||||
|
||||
sources = [
|
||||
'gdi_softpipe_winsys.c',
|
||||
]
|
||||
|
||||
if env['gcc']:
|
||||
sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def']
|
||||
else:
|
||||
sources += ['#src/gallium/state_trackers/wgl/opengl32.def']
|
||||
|
||||
drivers = [
|
||||
trace,
|
||||
softpipe,
|
||||
]
|
||||
if 'llvmpipe' in env['drivers']:
|
||||
sources = ['gdi_llvmpipe_winsys.c']
|
||||
drivers = [llvmpipe]
|
||||
env.Tool('llvm')
|
||||
elif 'softpipe' in env['drivers']:
|
||||
sources = ['gdi_softpipe_winsys.c']
|
||||
drivers = [softpipe]
|
||||
else:
|
||||
print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
|
||||
Return()
|
||||
|
||||
if env['gcc']:
|
||||
sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def']
|
||||
else:
|
||||
sources += ['#src/gallium/state_trackers/wgl/opengl32.def']
|
||||
|
||||
drivers += [trace]
|
||||
|
||||
env.SharedLibrary(
|
||||
target ='opengl32',
|
||||
source = sources,
|
||||
LIBS = wgl + glapi + mesa + drivers + auxiliaries + glsl + env['LIBS'],
|
||||
)
|
||||
env.SharedLibrary(
|
||||
target ='opengl32',
|
||||
source = sources,
|
||||
LIBS = wgl + glapi + mesa + drivers + auxiliaries + glsl + env['LIBS'],
|
||||
)
|
||||
|
|
|
|||
284
src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
Normal file
284
src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
Normal file
|
|
@ -0,0 +1,284 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* 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 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
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* LLVMpipe support.
|
||||
*
|
||||
* @author Jose Fonseca <jfonseca@vmware.com>
|
||||
*/
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "pipe/p_format.h"
|
||||
#include "pipe/p_context.h"
|
||||
#include "pipe/p_inlines.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "llvmpipe/lp_winsys.h"
|
||||
#include "llvmpipe/lp_texture.h"
|
||||
#include "shared/stw_winsys.h"
|
||||
|
||||
|
||||
struct gdi_llvmpipe_displaytarget
|
||||
{
|
||||
enum pipe_format format;
|
||||
struct pipe_format_block block;
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
unsigned stride;
|
||||
|
||||
unsigned size;
|
||||
|
||||
void *data;
|
||||
|
||||
BITMAPINFO bmi;
|
||||
};
|
||||
|
||||
|
||||
/** Cast wrapper */
|
||||
static INLINE struct gdi_llvmpipe_displaytarget *
|
||||
gdi_llvmpipe_displaytarget( struct llvmpipe_displaytarget *buf )
|
||||
{
|
||||
return (struct gdi_llvmpipe_displaytarget *)buf;
|
||||
}
|
||||
|
||||
|
||||
static boolean
|
||||
gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws,
|
||||
enum pipe_format format )
|
||||
{
|
||||
switch(format) {
|
||||
case PIPE_FORMAT_X8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
return TRUE;
|
||||
|
||||
/* TODO: Support other formats possible with BMPs, as described in
|
||||
* http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void *
|
||||
gdi_llvmpipe_displaytarget_map(struct llvmpipe_winsys *ws,
|
||||
struct llvmpipe_displaytarget *dt,
|
||||
unsigned flags )
|
||||
{
|
||||
struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt);
|
||||
|
||||
return gdt->data;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdi_llvmpipe_displaytarget_unmap(struct llvmpipe_winsys *ws,
|
||||
struct llvmpipe_displaytarget *dt )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys,
|
||||
struct llvmpipe_displaytarget *dt)
|
||||
{
|
||||
struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt);
|
||||
|
||||
align_free(gdt->data);
|
||||
FREE(gdt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Round n up to next multiple.
|
||||
*/
|
||||
static INLINE unsigned
|
||||
round_up(unsigned n, unsigned multiple)
|
||||
{
|
||||
return (n + multiple - 1) & ~(multiple - 1);
|
||||
}
|
||||
|
||||
|
||||
static struct llvmpipe_displaytarget *
|
||||
gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
|
||||
enum pipe_format format,
|
||||
unsigned width, unsigned height,
|
||||
unsigned alignment,
|
||||
unsigned *stride)
|
||||
{
|
||||
struct gdi_llvmpipe_displaytarget *gdt;
|
||||
unsigned cpp;
|
||||
unsigned bpp;
|
||||
|
||||
gdt = CALLOC_STRUCT(gdi_llvmpipe_displaytarget);
|
||||
if(!gdt)
|
||||
goto no_gdt;
|
||||
|
||||
gdt->format = format;
|
||||
gdt->width = width;
|
||||
gdt->height = height;
|
||||
|
||||
bpp = pf_get_bits(format);
|
||||
cpp = pf_get_size(format);
|
||||
|
||||
gdt->stride = round_up(width * cpp, alignment);
|
||||
gdt->size = gdt->stride * height;
|
||||
|
||||
gdt->data = align_malloc(gdt->size, alignment);
|
||||
if(!gdt->data)
|
||||
goto no_data;
|
||||
|
||||
gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp;
|
||||
gdt->bmi.bmiHeader.biHeight= -(long)height;
|
||||
gdt->bmi.bmiHeader.biPlanes = 1;
|
||||
gdt->bmi.bmiHeader.biBitCount = bpp;
|
||||
gdt->bmi.bmiHeader.biCompression = BI_RGB;
|
||||
gdt->bmi.bmiHeader.biSizeImage = 0;
|
||||
gdt->bmi.bmiHeader.biXPelsPerMeter = 0;
|
||||
gdt->bmi.bmiHeader.biYPelsPerMeter = 0;
|
||||
gdt->bmi.bmiHeader.biClrUsed = 0;
|
||||
gdt->bmi.bmiHeader.biClrImportant = 0;
|
||||
|
||||
*stride = gdt->stride;
|
||||
return (struct llvmpipe_displaytarget *)gdt;
|
||||
|
||||
no_data:
|
||||
FREE(gdt);
|
||||
no_gdt:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdi_llvmpipe_displaytarget_display(struct llvmpipe_winsys *winsys,
|
||||
struct llvmpipe_displaytarget *dt,
|
||||
void *context_private)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdi_llvmpipe_destroy(struct llvmpipe_winsys *winsys)
|
||||
{
|
||||
FREE(winsys);
|
||||
}
|
||||
|
||||
|
||||
static struct pipe_screen *
|
||||
gdi_llvmpipe_screen_create(void)
|
||||
{
|
||||
static struct llvmpipe_winsys *winsys;
|
||||
struct pipe_screen *screen;
|
||||
|
||||
winsys = CALLOC_STRUCT(llvmpipe_winsys);
|
||||
if(!winsys)
|
||||
goto no_winsys;
|
||||
|
||||
winsys->destroy = gdi_llvmpipe_destroy;
|
||||
winsys->is_displaytarget_format_supported = gdi_llvmpipe_is_displaytarget_format_supported;
|
||||
winsys->displaytarget_create = gdi_llvmpipe_displaytarget_create;
|
||||
winsys->displaytarget_map = gdi_llvmpipe_displaytarget_map;
|
||||
winsys->displaytarget_unmap = gdi_llvmpipe_displaytarget_unmap;
|
||||
winsys->displaytarget_display = gdi_llvmpipe_displaytarget_display;
|
||||
winsys->displaytarget_destroy = gdi_llvmpipe_displaytarget_destroy;
|
||||
|
||||
screen = llvmpipe_create_screen(winsys);
|
||||
if(!screen)
|
||||
goto no_screen;
|
||||
|
||||
return screen;
|
||||
|
||||
no_screen:
|
||||
FREE(winsys);
|
||||
no_winsys:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static struct pipe_context *
|
||||
gdi_llvmpipe_context_create(struct pipe_screen *screen)
|
||||
{
|
||||
return llvmpipe_create(screen);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gdi_llvmpipe_flush_frontbuffer(struct pipe_screen *screen,
|
||||
struct pipe_surface *surface,
|
||||
HDC hDC)
|
||||
{
|
||||
struct llvmpipe_texture *texture;
|
||||
struct gdi_llvmpipe_displaytarget *gdt;
|
||||
|
||||
texture = llvmpipe_texture(surface->texture);
|
||||
gdt = gdi_llvmpipe_displaytarget(texture->dt);
|
||||
|
||||
StretchDIBits(hDC,
|
||||
0, 0, gdt->width, gdt->height,
|
||||
0, 0, gdt->width, gdt->height,
|
||||
gdt->data, &gdt->bmi, 0, SRCCOPY);
|
||||
}
|
||||
|
||||
|
||||
static const struct stw_winsys stw_winsys = {
|
||||
&gdi_llvmpipe_screen_create,
|
||||
&gdi_llvmpipe_context_create,
|
||||
&gdi_llvmpipe_flush_frontbuffer
|
||||
};
|
||||
|
||||
|
||||
BOOL WINAPI
|
||||
DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
||||
{
|
||||
switch (fdwReason) {
|
||||
case DLL_PROCESS_ATTACH:
|
||||
if (!stw_init(&stw_winsys)) {
|
||||
return FALSE;
|
||||
}
|
||||
return stw_init_thread();
|
||||
|
||||
case DLL_THREAD_ATTACH:
|
||||
return stw_init_thread();
|
||||
|
||||
case DLL_THREAD_DETACH:
|
||||
stw_cleanup_thread();
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH:
|
||||
stw_cleanup_thread();
|
||||
stw_cleanup();
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ XLIB_WINSYS_SOURCES = \
|
|||
xlib_brw_aub.c \
|
||||
xlib_brw_context.c \
|
||||
xlib_brw_screen.c \
|
||||
xlib_llvmpipe.c \
|
||||
xlib_softpipe.c \
|
||||
xlib_trace.c
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
*/
|
||||
|
||||
|
||||
#if defined(GALLIUM_LLVMPIPE)
|
||||
|
||||
#include "xm_api.h"
|
||||
|
||||
#undef ASSERT
|
||||
|
|
@ -459,3 +461,4 @@ struct xm_driver xlib_llvmpipe_driver =
|
|||
|
||||
|
||||
|
||||
#endif /* GALLIUM_LLVMPIPE */
|
||||
|
|
|
|||
|
|
@ -40,6 +40,23 @@
|
|||
#include "glcontextmodes.h"
|
||||
|
||||
|
||||
/**
|
||||
* Emit a warning when clients use GLX 1.3 functions on pre-1.3 systems.
|
||||
*/
|
||||
static void
|
||||
warn_GLX_1_3(Display *dpy, const char *function_name)
|
||||
{
|
||||
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
|
||||
|
||||
if (priv->minorVersion < 3) {
|
||||
fprintf(stderr,
|
||||
"WARNING: Application calling GLX 1.3 function \"%s\" "
|
||||
"when GLX 1.3 is not supported! This is an application bug!\n",
|
||||
function_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Change a drawable's attribute.
|
||||
*
|
||||
|
|
@ -559,6 +576,8 @@ glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list)
|
|||
width = 0;
|
||||
height = 0;
|
||||
|
||||
warn_GLX_1_3(dpy, __func__);
|
||||
|
||||
for (i = 0; attrib_list[i * 2]; i++) {
|
||||
switch (attrib_list[i * 2]) {
|
||||
case GLX_PBUFFER_WIDTH:
|
||||
|
|
@ -592,6 +611,7 @@ PUBLIC void
|
|||
glXQueryDrawable(Display * dpy, GLXDrawable drawable,
|
||||
int attribute, unsigned int *value)
|
||||
{
|
||||
warn_GLX_1_3(dpy, __func__);
|
||||
GetDrawableAttribute(dpy, drawable, attribute, value);
|
||||
}
|
||||
|
||||
|
|
@ -645,6 +665,8 @@ PUBLIC GLXPixmap
|
|||
glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
|
||||
const int *attrib_list)
|
||||
{
|
||||
warn_GLX_1_3(dpy, __func__);
|
||||
|
||||
return CreateDrawable(dpy, (__GLcontextModes *) config,
|
||||
(Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
|
||||
}
|
||||
|
|
@ -654,6 +676,8 @@ PUBLIC GLXWindow
|
|||
glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
|
||||
const int *attrib_list)
|
||||
{
|
||||
warn_GLX_1_3(dpy, __func__);
|
||||
|
||||
return CreateDrawable(dpy, (__GLcontextModes *) config,
|
||||
(Drawable) win, attrib_list, X_GLXCreateWindow);
|
||||
}
|
||||
|
|
@ -662,6 +686,8 @@ glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
|
|||
PUBLIC void
|
||||
glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
|
||||
{
|
||||
warn_GLX_1_3(dpy, __func__);
|
||||
|
||||
DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
|
||||
}
|
||||
|
||||
|
|
@ -669,6 +695,8 @@ glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
|
|||
PUBLIC void
|
||||
glXDestroyWindow(Display * dpy, GLXWindow win)
|
||||
{
|
||||
warn_GLX_1_3(dpy, __func__);
|
||||
|
||||
DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,29 @@
|
|||
#define OFFSET(FIELD) ((void *) offsetof(struct vertex, FIELD))
|
||||
|
||||
|
||||
/**
|
||||
* Flags passed to _mesa_meta_begin().
|
||||
*/
|
||||
/*@{*/
|
||||
#define META_ALL ~0x0
|
||||
#define META_ALPHA_TEST 0x1
|
||||
#define META_BLEND 0x2 /**< includes logicop */
|
||||
#define META_COLOR_MASK 0x4
|
||||
#define META_DEPTH_TEST 0x8
|
||||
#define META_FOG 0x10
|
||||
#define META_PIXEL_STORE 0x20
|
||||
#define META_PIXEL_TRANSFER 0x40
|
||||
#define META_RASTERIZATION 0x80
|
||||
#define META_SCISSOR 0x100
|
||||
#define META_SHADER 0x200
|
||||
#define META_STENCIL_TEST 0x400
|
||||
#define META_TRANSFORM 0x800 /**< modelview, projection, clip planes */
|
||||
#define META_TEXTURE 0x1000
|
||||
#define META_VERTEX 0x2000
|
||||
#define META_VIEWPORT 0x4000
|
||||
/*@}*/
|
||||
|
||||
|
||||
/**
|
||||
* State which we may save/restore across meta ops.
|
||||
* XXX this may be incomplete...
|
||||
|
|
@ -94,6 +117,17 @@ struct save_state
|
|||
/** META_PIXEL_STORE */
|
||||
struct gl_pixelstore_attrib Pack, Unpack;
|
||||
|
||||
/** META_PIXEL_TRANSFER */
|
||||
GLfloat RedBias, RedScale;
|
||||
GLfloat GreenBias, GreenScale;
|
||||
GLfloat BlueBias, BlueScale;
|
||||
GLfloat AlphaBias, AlphaScale;
|
||||
GLfloat DepthBias, DepthScale;
|
||||
GLboolean MapColorFlag;
|
||||
GLboolean Convolution1DEnabled;
|
||||
GLboolean Convolution2DEnabled;
|
||||
GLboolean Separable2DEnabled;
|
||||
|
||||
/** META_RASTERIZATION */
|
||||
GLenum FrontPolygonMode, BackPolygonMode;
|
||||
GLboolean PolygonOffset;
|
||||
|
|
@ -363,6 +397,35 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
|
|||
ctx->Unpack = ctx->DefaultPacking;
|
||||
}
|
||||
|
||||
if (state & META_PIXEL_TRANSFER) {
|
||||
save->RedScale = ctx->Pixel.RedScale;
|
||||
save->RedBias = ctx->Pixel.RedBias;
|
||||
save->GreenScale = ctx->Pixel.GreenScale;
|
||||
save->GreenBias = ctx->Pixel.GreenBias;
|
||||
save->BlueScale = ctx->Pixel.BlueScale;
|
||||
save->BlueBias = ctx->Pixel.BlueBias;
|
||||
save->AlphaScale = ctx->Pixel.AlphaScale;
|
||||
save->AlphaBias = ctx->Pixel.AlphaBias;
|
||||
save->MapColorFlag = ctx->Pixel.MapColorFlag;
|
||||
save->Convolution1DEnabled = ctx->Pixel.Convolution1DEnabled;
|
||||
save->Convolution2DEnabled = ctx->Pixel.Convolution2DEnabled;
|
||||
save->Separable2DEnabled = ctx->Pixel.Separable2DEnabled;
|
||||
ctx->Pixel.RedScale = 1.0F;
|
||||
ctx->Pixel.RedBias = 0.0F;
|
||||
ctx->Pixel.GreenScale = 1.0F;
|
||||
ctx->Pixel.GreenBias = 0.0F;
|
||||
ctx->Pixel.BlueScale = 1.0F;
|
||||
ctx->Pixel.BlueBias = 0.0F;
|
||||
ctx->Pixel.AlphaScale = 1.0F;
|
||||
ctx->Pixel.AlphaBias = 0.0F;
|
||||
ctx->Pixel.MapColorFlag = GL_FALSE;
|
||||
ctx->Pixel.Convolution1DEnabled = GL_FALSE;
|
||||
ctx->Pixel.Convolution2DEnabled = GL_FALSE;
|
||||
ctx->Pixel.Separable2DEnabled = GL_FALSE;
|
||||
/* XXX more state */
|
||||
ctx->NewState |=_NEW_PIXEL;
|
||||
}
|
||||
|
||||
if (state & META_RASTERIZATION) {
|
||||
save->FrontPolygonMode = ctx->Polygon.FrontMode;
|
||||
save->BackPolygonMode = ctx->Polygon.BackMode;
|
||||
|
|
@ -415,11 +478,6 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
|
|||
save->ClientActiveUnit = ctx->Array.ActiveTexture;
|
||||
save->EnvMode = ctx->Texture.Unit[0].EnvMode;
|
||||
|
||||
if (ctx->Texture._EnabledUnits |
|
||||
ctx->Texture._EnabledCoordUnits |
|
||||
ctx->Texture._TexGenEnabled |
|
||||
ctx->Texture._TexMatEnabled) {
|
||||
|
||||
/* Disable all texture units */
|
||||
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
|
||||
save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled;
|
||||
|
|
@ -438,7 +496,6 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
|
|||
_mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* save current texture objects for unit[0] only */
|
||||
for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) {
|
||||
|
|
@ -564,6 +621,23 @@ _mesa_meta_end(GLcontext *ctx)
|
|||
ctx->Unpack = save->Unpack;
|
||||
}
|
||||
|
||||
if (state & META_PIXEL_TRANSFER) {
|
||||
ctx->Pixel.RedScale = save->RedScale;
|
||||
ctx->Pixel.RedBias = save->RedBias;
|
||||
ctx->Pixel.GreenScale = save->GreenScale;
|
||||
ctx->Pixel.GreenBias = save->GreenBias;
|
||||
ctx->Pixel.BlueScale = save->BlueScale;
|
||||
ctx->Pixel.BlueBias = save->BlueBias;
|
||||
ctx->Pixel.AlphaScale = save->AlphaScale;
|
||||
ctx->Pixel.AlphaBias = save->AlphaBias;
|
||||
ctx->Pixel.MapColorFlag = save->MapColorFlag;
|
||||
ctx->Pixel.Convolution1DEnabled = save->Convolution1DEnabled;
|
||||
ctx->Pixel.Convolution2DEnabled = save->Convolution2DEnabled;
|
||||
ctx->Pixel.Separable2DEnabled = save->Separable2DEnabled;
|
||||
/* XXX more state */
|
||||
ctx->NewState |=_NEW_PIXEL;
|
||||
}
|
||||
|
||||
if (state & META_RASTERIZATION) {
|
||||
_mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode);
|
||||
_mesa_PolygonMode(GL_BACK, save->BackPolygonMode);
|
||||
|
|
@ -2037,3 +2111,231 @@ _mesa_meta_generate_mipmap(GLcontext *ctx, GLenum target,
|
|||
/* restore (XXX add to meta_begin/end()? */
|
||||
_mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the GL data type to use for the temporary image read with
|
||||
* ReadPixels() and passed to Tex[Sub]Image().
|
||||
*/
|
||||
static GLenum
|
||||
get_temp_image_type(GLcontext *ctx, GLenum baseFormat)
|
||||
{
|
||||
switch (baseFormat) {
|
||||
case GL_RGBA:
|
||||
case GL_RGB:
|
||||
case GL_ALPHA:
|
||||
case GL_LUMINANCE:
|
||||
case GL_LUMINANCE_ALPHA:
|
||||
case GL_INTENSITY:
|
||||
if (ctx->DrawBuffer->Visual.redBits <= 8)
|
||||
return GL_UNSIGNED_BYTE;
|
||||
else if (ctx->DrawBuffer->Visual.redBits <= 8)
|
||||
return GL_UNSIGNED_SHORT;
|
||||
else
|
||||
return GL_FLOAT;
|
||||
case GL_DEPTH_COMPONENT:
|
||||
return GL_UNSIGNED_INT;
|
||||
case GL_DEPTH_STENCIL:
|
||||
return GL_UNSIGNED_INT_24_8;
|
||||
default:
|
||||
_mesa_problem(ctx, "Unexpected format in get_temp_image_type()");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper for _mesa_meta_CopyTexImage1/2D() functions.
|
||||
* Have to be careful with locking and meta state for pixel transfer.
|
||||
*/
|
||||
static void
|
||||
copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level,
|
||||
GLenum internalFormat, GLint x, GLint y,
|
||||
GLsizei width, GLsizei height, GLint border)
|
||||
{
|
||||
struct gl_texture_unit *texUnit;
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
GLenum format, type;
|
||||
GLint bpp;
|
||||
void *buf;
|
||||
|
||||
texUnit = _mesa_get_current_tex_unit(ctx);
|
||||
texObj = _mesa_select_tex_object(ctx, texUnit, target);
|
||||
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
|
||||
|
||||
format = _mesa_base_tex_format(ctx, internalFormat);
|
||||
type = get_temp_image_type(ctx, format);
|
||||
bpp = _mesa_bytes_per_pixel(format, type);
|
||||
if (bpp <= 0) {
|
||||
_mesa_problem(ctx, "Bad bpp in meta copy_tex_image()");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Alloc image buffer (XXX could use a PBO)
|
||||
*/
|
||||
buf = _mesa_malloc(width * height * bpp);
|
||||
if (!buf) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage%uD", dims);
|
||||
return;
|
||||
}
|
||||
|
||||
_mesa_unlock_texture(ctx, texObj); /* need to unlock first */
|
||||
|
||||
/*
|
||||
* Read image from framebuffer (disable pixel transfer ops)
|
||||
*/
|
||||
_mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
|
||||
ctx->Driver.ReadPixels(ctx, x, y, width, height,
|
||||
format, type, &ctx->Pack, buf);
|
||||
_mesa_meta_end(ctx);
|
||||
|
||||
/*
|
||||
* Store texture data (with pixel transfer ops)
|
||||
*/
|
||||
_mesa_meta_begin(ctx, META_PIXEL_STORE);
|
||||
if (target == GL_TEXTURE_1D) {
|
||||
ctx->Driver.TexImage1D(ctx, target, level, internalFormat,
|
||||
width, border, format, type,
|
||||
buf, &ctx->Unpack, texObj, texImage);
|
||||
}
|
||||
else {
|
||||
ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
|
||||
width, height, border, format, type,
|
||||
buf, &ctx->Unpack, texObj, texImage);
|
||||
}
|
||||
_mesa_meta_end(ctx);
|
||||
|
||||
_mesa_lock_texture(ctx, texObj); /* re-lock */
|
||||
|
||||
_mesa_free(buf);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_meta_CopyTexImage1D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat, GLint x, GLint y,
|
||||
GLsizei width, GLint border)
|
||||
{
|
||||
copy_tex_image(ctx, 1, target, level, internalFormat, x, y,
|
||||
width, 1, border);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_meta_CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat, GLint x, GLint y,
|
||||
GLsizei width, GLsizei height, GLint border)
|
||||
{
|
||||
copy_tex_image(ctx, 2, target, level, internalFormat, x, y,
|
||||
width, height, border);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Helper for _mesa_meta_CopyTexSubImage1/2/3D() functions.
|
||||
* Have to be careful with locking and meta state for pixel transfer.
|
||||
*/
|
||||
static void
|
||||
copy_tex_sub_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
struct gl_texture_unit *texUnit;
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
GLenum format, type;
|
||||
GLint bpp;
|
||||
void *buf;
|
||||
|
||||
texUnit = _mesa_get_current_tex_unit(ctx);
|
||||
texObj = _mesa_select_tex_object(ctx, texUnit, target);
|
||||
texImage = _mesa_select_tex_image(ctx, texObj, target, level);
|
||||
|
||||
format = texImage->TexFormat->BaseFormat;
|
||||
type = get_temp_image_type(ctx, format);
|
||||
bpp = _mesa_bytes_per_pixel(format, type);
|
||||
if (bpp <= 0) {
|
||||
_mesa_problem(ctx, "Bad bpp in meta copy_tex_sub_image()");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Alloc image buffer (XXX could use a PBO)
|
||||
*/
|
||||
buf = _mesa_malloc(width * height * bpp);
|
||||
if (!buf) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage%uD", dims);
|
||||
return;
|
||||
}
|
||||
|
||||
_mesa_unlock_texture(ctx, texObj); /* need to unlock first */
|
||||
|
||||
/*
|
||||
* Read image from framebuffer (disable pixel transfer ops)
|
||||
*/
|
||||
_mesa_meta_begin(ctx, META_PIXEL_STORE | META_PIXEL_TRANSFER);
|
||||
ctx->Driver.ReadPixels(ctx, x, y, width, height,
|
||||
format, type, &ctx->Pack, buf);
|
||||
_mesa_meta_end(ctx);
|
||||
|
||||
/*
|
||||
* Store texture data (with pixel transfer ops)
|
||||
*/
|
||||
_mesa_meta_begin(ctx, META_PIXEL_STORE);
|
||||
if (target == GL_TEXTURE_1D) {
|
||||
ctx->Driver.TexSubImage1D(ctx, target, level, xoffset,
|
||||
width, format, type, buf,
|
||||
&ctx->Unpack, texObj, texImage);
|
||||
}
|
||||
else if (target == GL_TEXTURE_3D) {
|
||||
ctx->Driver.TexSubImage3D(ctx, target, level, xoffset, yoffset, zoffset,
|
||||
width, height, 1, format, type, buf,
|
||||
&ctx->Unpack, texObj, texImage);
|
||||
}
|
||||
else {
|
||||
ctx->Driver.TexSubImage2D(ctx, target, level, xoffset, yoffset,
|
||||
width, height, format, type, buf,
|
||||
&ctx->Unpack, texObj, texImage);
|
||||
}
|
||||
_mesa_meta_end(ctx);
|
||||
|
||||
_mesa_lock_texture(ctx, texObj); /* re-lock */
|
||||
|
||||
_mesa_free(buf);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_meta_CopyTexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset,
|
||||
GLint x, GLint y, GLsizei width)
|
||||
{
|
||||
copy_tex_sub_image(ctx, 1, target, level, xoffset, 0, 0,
|
||||
x, y, width, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_meta_CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
copy_tex_sub_image(ctx, 2, target, level, xoffset, yoffset, 0,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_mesa_meta_CopyTexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height)
|
||||
{
|
||||
copy_tex_sub_image(ctx, 3, target, level, xoffset, yoffset, zoffset,
|
||||
x, y, width, height);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,29 +27,6 @@
|
|||
#define META_H
|
||||
|
||||
|
||||
/**
|
||||
* Flags passed to _mesa_meta_begin().
|
||||
* XXX these flags may evolve...
|
||||
*/
|
||||
/*@{*/
|
||||
#define META_ALPHA_TEST 0x1
|
||||
#define META_BLEND 0x2 /**< includes logicop */
|
||||
#define META_COLOR_MASK 0x4
|
||||
#define META_DEPTH_TEST 0x8
|
||||
#define META_FOG 0x10
|
||||
#define META_RASTERIZATION 0x20
|
||||
#define META_SCISSOR 0x40
|
||||
#define META_SHADER 0x80
|
||||
#define META_STENCIL_TEST 0x100
|
||||
#define META_TRANSFORM 0x200 /**< modelview, projection */
|
||||
#define META_TEXTURE 0x400
|
||||
#define META_VERTEX 0x800
|
||||
#define META_VIEWPORT 0x1000
|
||||
#define META_PIXEL_STORE 0x2000
|
||||
#define META_ALL ~0x0
|
||||
/*@}*/
|
||||
|
||||
|
||||
extern void
|
||||
_mesa_meta_init(GLcontext *ctx);
|
||||
|
||||
|
|
@ -87,5 +64,32 @@ extern void
|
|||
_mesa_meta_generate_mipmap(GLcontext *ctx, GLenum target,
|
||||
struct gl_texture_object *texObj);
|
||||
|
||||
extern void
|
||||
_mesa_meta_CopyTexImage1D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat, GLint x, GLint y,
|
||||
GLsizei width, GLint border);
|
||||
|
||||
extern void
|
||||
_mesa_meta_CopyTexImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLenum internalFormat, GLint x, GLint y,
|
||||
GLsizei width, GLsizei height, GLint border);
|
||||
|
||||
extern void
|
||||
_mesa_meta_CopyTexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset,
|
||||
GLint x, GLint y, GLsizei width);
|
||||
|
||||
extern void
|
||||
_mesa_meta_CopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height);
|
||||
|
||||
extern void
|
||||
_mesa_meta_CopyTexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset, GLint zoffset,
|
||||
GLint x, GLint y,
|
||||
GLsizei width, GLsizei height);
|
||||
|
||||
|
||||
#endif /* META_H */
|
||||
|
|
|
|||
|
|
@ -30,24 +30,6 @@
|
|||
#include "ffb_tex.h"
|
||||
|
||||
/* No texture unit, all software. */
|
||||
/* XXX this function isn't needed since _mesa_init_driver_functions()
|
||||
* will make all these assignments.
|
||||
*/
|
||||
void ffbDDInitTexFuncs(GLcontext *ctx)
|
||||
{
|
||||
/*
|
||||
ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
|
||||
ctx->Driver.TexImage1D = _mesa_store_teximage1d;
|
||||
ctx->Driver.TexImage2D = _mesa_store_teximage2d;
|
||||
ctx->Driver.TexImage3D = _mesa_store_teximage3d;
|
||||
ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
|
||||
ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
|
||||
ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
|
||||
ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
|
||||
ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
|
||||
ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
|
||||
ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
|
||||
ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
|
||||
ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue