Merge commit 'origin/gallium-0.2' into gallium-master-merge

This commit is contained in:
Brian Paul 2009-02-10 16:34:51 -07:00
commit ee4c921b65
46 changed files with 876 additions and 534 deletions

View File

@ -1,6 +1,8 @@
SConscript([
'util/SConscript',
'demos/SConscript',
'redbook/SConscript',
'samples/SConscript',
'trivial/SConscript',
'vp/SConscript',
])

91
progs/redbook/SConscript Normal file
View File

@ -0,0 +1,91 @@
Import('*')
if not env['GLUT']:
Return()
env = env.Clone()
env.Prepend(CPPPATH = [
'../util',
])
env.Prepend(LIBS = [
util,
'$GLUT_LIB'
])
if env['platform'] == 'windows':
env.Append(CPPDEFINES = ['NOMINMAX'])
env.Prepend(LIBS = ['winmm'])
progs = [
'aaindex',
'aapoly',
'aargb',
'accanti',
'accpersp',
'alpha3D',
'alpha',
'anti',
'bezcurve',
'bezmesh',
'checker',
'clip',
'colormat',
'cube',
'depthcue',
'dof',
'double',
'drawf',
'feedback',
'fog',
'fogindex',
'font',
'hello',
'image',
'light',
'lines',
'list',
'material',
'mipmap',
'model',
'movelight',
'nurbs',
'pickdepth',
'picksquare',
'plane',
'planet',
'polyoff',
'polys',
'quadric',
'robot',
'sccolorlight',
'scenebamb',
'scene',
'sceneflat',
'select',
'smooth',
'stencil',
'stroke',
'surface',
'teaambient',
'teapots',
'tess',
'tesswind',
'texbind',
'texgen',
'texprox',
'texsub',
'texturesurf',
'torus',
'trim',
'unproject',
'varray',
'wrap',
]
for prog in progs:
env.Program(
target = prog,
source = prog + '.c',
)

View File

@ -7,7 +7,7 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
font line logo nurb olympic overlay point prim quad select \

58
progs/samples/SConscript Normal file
View File

@ -0,0 +1,58 @@
Import('*')
if not env['GLUT']:
Return()
env = env.Clone()
env.Prepend(CPPPATH = [
'../util',
])
env.Prepend(LIBS = [
util,
'$GLUT_LIB'
])
if env['platform'] == 'windows':
env.Append(CPPDEFINES = ['NOMINMAX'])
env.Prepend(LIBS = ['winmm'])
progs = [
'accum',
'bitmap1',
'bitmap2',
'blendeq',
'blendxor',
'copy',
'cursor',
'depth',
'eval',
'fog',
'font',
'line',
'logo',
'nurb',
#'oglinfo',
'olympic',
'overlay',
'point',
'prim',
'quad',
'rgbtoppm',
'select',
'shape',
'sphere',
'star',
'stencil',
'stretch',
'texture',
'tri',
'wave',
]
for prog in progs:
env.Program(
target = prog,
source = prog + '.c',
)

View File

@ -11,10 +11,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
GLenum doubleBuffer;
@ -274,6 +271,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
/* Make sure blend_logic_op extension is there. */
s = (char *) glGetString(GL_EXTENSIONS);
version = (char*) glGetString(GL_VERSION);

View File

@ -10,13 +10,8 @@
#include <unistd.h>
#endif
#include <stdlib.h>
#ifdef _WIN32
#include <windows.h>
#endif
#define GL_GLEXT_LEGACY
#define GL_GLEXT_PROTOTYPES
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glext.h>
GLenum doubleBuffer;
@ -176,6 +171,8 @@ int main(int argc, char **argv)
exit(1);
}
glewInit();
/* Make sure blend_logic_op extension is there. */
s = (char *) glGetString(GL_EXTENSIONS);
version = (char*) glGetString(GL_VERSION);

View File

@ -163,6 +163,25 @@ def createInstallMethods(env):
env.AddMethod(install_shared_library, 'InstallSharedLibrary')
def num_jobs():
try:
return int(os.environ['NUMBER_OF_PROCESSORS'])
except (ValueError, KeyError):
pass
try:
return os.sysconf('SC_NPROCESSORS_ONLN')
except (ValueError, OSError, AttributeError):
pass
try:
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
except ValueError:
pass
return 1
def generate(env):
"""Common environment generation code"""
@ -207,6 +226,10 @@ def generate(env):
env.SConsignFile(os.path.join(build_dir, '.sconsign'))
env.CacheDir('build/cache')
# Parallel build
if env.GetOption('num_jobs') <= 1:
env.SetOption('num_jobs', num_jobs())
# C preprocessor options
cppdefines = []
if debug:

View File

@ -206,6 +206,25 @@ _bool_map = {
}
def num_jobs():
try:
return int(os.environ['NUMBER_OF_PROCESSORS'])
except (ValueError, KeyError):
pass
try:
return os.sysconf('SC_NPROCESSORS_ONLN')
except (ValueError, OSError, AttributeError):
pass
try:
return int(os.popen2("sysctl -n hw.ncpu")[1].read())
except ValueError:
pass
return 1
def generate(env):
"""Common environment generation code"""
@ -266,6 +285,10 @@ def generate(env):
# different scons versions building the same source file
env.SConsignFile(os.path.join(env['build'], '.sconsign'))
# Parallel build
if env.GetOption('num_jobs') <= 1:
env.SetOption('num_jobs', num_jobs())
# Summary
print
print ' platform=%s' % env['platform']
@ -274,6 +297,7 @@ def generate(env):
print ' debug=%s' % ['no', 'yes'][env['debug']]
print ' profile=%s' % ['no', 'yes'][env['profile']]
print ' build=%s' % env['build']
print ' %s jobs' % env.GetOption('num_jobs')
print
# Load tool chain

View File

@ -256,7 +256,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
struct tgsi_full_immediate immed;
uint size = 4;
immed = tgsi_default_full_immediate();
immed.Immediate.Size = 1 + size; /* one for the token itself */
immed.Immediate.NrTokens = 1 + size; /* one for the token itself */
immed.u.Pointer = (void *) value;
ctx->emit_immediate(ctx, &immed);
}

View File

@ -1870,7 +1870,7 @@ static boolean note_immediate( struct aos_compilation *cp,
unsigned pos = cp->num_immediates++;
unsigned j;
for (j = 0; j < imm->Immediate.Size; j++) {
for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
cp->vaos->machine->immediate[pos][j] = imm->u.ImmediateFloat32[j].Float;
}

View File

@ -160,7 +160,7 @@ translate_immediate(Storage *storage,
{
float vec[4];
int i;
for (i = 0; i < imm->Immediate.Size - 1; ++i) {
for (i = 0; i < imm->Immediate.NrTokens - 1; ++i) {
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
vec[i] = imm->u.ImmediateFloat32[i].Float;
@ -179,7 +179,7 @@ translate_immediateir(StorageSoa *storage,
{
float vec[4];
int i;
for (i = 0; i < imm->Immediate.Size - 1; ++i) {
for (i = 0; i < imm->Immediate.NrTokens - 1; ++i) {
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
vec[i] = imm->u.ImmediateFloat32[i].Float;

File diff suppressed because it is too large Load Diff

View File

@ -157,7 +157,7 @@ def preamble(intype, outtype, inpv, outpv, prim):
print ' void *_out )'
print '{'
if intype != GENERATE:
print ' const ' + intype + '*in = (const ' + intype + '*)in;'
print ' const ' + intype + '*in = (const ' + intype + '*)_in;'
print ' ' + outtype + ' *out = (' + outtype + '*)_out;'
print ' unsigned i, j;'
print ' (void)j;'

View File

@ -44,7 +44,6 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
#include "pipe/p_debug.h"
#include "pipe/internal/p_winsys_screen.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@ -64,7 +63,7 @@ struct fenced_buffer_list
{
pipe_mutex mutex;
struct pipe_winsys *winsys;
struct pb_fence_ops *ops;
size_t numDelayed;
@ -140,12 +139,12 @@ static INLINE void
_fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
struct fenced_buffer *fenced_buf)
{
struct pipe_winsys *winsys = fenced_list->winsys;
struct pb_fence_ops *ops = fenced_list->ops;
assert(fenced_buf->fence);
assert(fenced_buf->list == fenced_list);
winsys->fence_reference(winsys, &fenced_buf->fence, NULL);
ops->fence_reference(ops, &fenced_buf->fence, NULL);
fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
assert(fenced_buf->head.prev);
@ -168,7 +167,7 @@ static INLINE enum pipe_error
_fenced_buffer_finish(struct fenced_buffer *fenced_buf)
{
struct fenced_buffer_list *fenced_list = fenced_buf->list;
struct pipe_winsys *winsys = fenced_list->winsys;
struct pb_fence_ops *ops = fenced_list->ops;
#if 0
debug_warning("waiting for GPU");
@ -176,7 +175,7 @@ _fenced_buffer_finish(struct fenced_buffer *fenced_buf)
assert(fenced_buf->fence);
if(fenced_buf->fence) {
if(winsys->fence_finish(winsys, fenced_buf->fence, 0) != 0) {
if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) {
return PIPE_ERROR;
}
/* Remove from the fenced list */
@ -196,7 +195,7 @@ static void
_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait)
{
struct pipe_winsys *winsys = fenced_list->winsys;
struct pb_fence_ops *ops = fenced_list->ops;
struct list_head *curr, *next;
struct fenced_buffer *fenced_buf;
struct pipe_fence_handle *prev_fence = NULL;
@ -209,15 +208,15 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
if(fenced_buf->fence != prev_fence) {
int signaled;
if (wait)
signaled = winsys->fence_finish(winsys, fenced_buf->fence, 0);
signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
else
signaled = winsys->fence_signalled(winsys, fenced_buf->fence, 0);
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
if (signaled != 0)
break;
prev_fence = fenced_buf->fence;
}
else {
assert(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0);
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
}
_fenced_buffer_remove(fenced_list, fenced_buf);
@ -237,14 +236,14 @@ fenced_buffer_destroy(struct pb_buffer *buf)
pipe_mutex_lock(fenced_list->mutex);
assert(fenced_buf->base.base.refcount == 0);
if (fenced_buf->fence) {
struct pipe_winsys *winsys = fenced_list->winsys;
if(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0) {
struct pb_fence_ops *ops = fenced_list->ops;
if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
struct list_head *curr, *prev;
curr = &fenced_buf->head;
prev = curr->prev;
do {
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
assert(winsys->fence_signalled(winsys, fenced_buf->fence, 0) == 0);
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
_fenced_buffer_remove(fenced_list, fenced_buf);
curr = prev;
prev = curr->prev;
@ -366,11 +365,11 @@ fenced_buffer_fence(struct pb_buffer *buf,
{
struct fenced_buffer *fenced_buf;
struct fenced_buffer_list *fenced_list;
struct pipe_winsys *winsys;
struct pb_fence_ops *ops;
fenced_buf = fenced_buffer(buf);
fenced_list = fenced_buf->list;
winsys = fenced_list->winsys;
ops = fenced_list->ops;
if(fence == fenced_buf->fence) {
/* Nothing to do */
@ -384,7 +383,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
if (fenced_buf->fence)
_fenced_buffer_remove(fenced_list, fenced_buf);
if (fence) {
winsys->fence_reference(winsys, &fenced_buf->fence, fence);
ops->fence_reference(ops, &fenced_buf->fence, fence);
fenced_buf->flags |= fenced_buf->validation_flags;
_fenced_buffer_add(fenced_buf);
}
@ -447,7 +446,7 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
struct fenced_buffer_list *
fenced_buffer_list_create(struct pipe_winsys *winsys)
fenced_buffer_list_create(struct pb_fence_ops *ops)
{
struct fenced_buffer_list *fenced_list;
@ -455,7 +454,7 @@ fenced_buffer_list_create(struct pipe_winsys *winsys)
if (!fenced_list)
return NULL;
fenced_list->winsys = winsys;
fenced_list->ops = ops;
LIST_INITHEAD(&fenced_list->delayed);
@ -494,6 +493,8 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
pipe_mutex_unlock(fenced_list->mutex);
fenced_list->ops->destroy(fenced_list->ops);
FREE(fenced_list);
}

View File

@ -59,7 +59,6 @@ extern "C" {
#endif
struct pipe_winsys;
struct pipe_buffer;
struct pipe_fence_handle;
@ -70,13 +69,42 @@ struct pipe_fence_handle;
struct fenced_buffer_list;
struct pb_fence_ops
{
void (*destroy)( struct pb_fence_ops *ops );
/** Set ptr = fence, with reference counting */
void (*fence_reference)( struct pb_fence_ops *ops,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence );
/**
* Checks whether the fence has been signalled.
* \param flags driver-specific meaning
* \return zero on success.
*/
int (*fence_signalled)( struct pb_fence_ops *ops,
struct pipe_fence_handle *fence,
unsigned flag );
/**
* Wait for the fence to finish.
* \param flags driver-specific meaning
* \return zero on success.
*/
int (*fence_finish)( struct pb_fence_ops *ops,
struct pipe_fence_handle *fence,
unsigned flag );
};
/**
* Create a fenced buffer list.
*
* See also fenced_bufmgr_create for a more convenient way to use this.
*/
struct fenced_buffer_list *
fenced_buffer_list_create(struct pipe_winsys *winsys);
fenced_buffer_list_create(struct pb_fence_ops *ops);
/**

View File

@ -61,7 +61,6 @@ extern "C" {
struct pb_desc;
struct pipe_buffer;
struct pipe_winsys;
/**
@ -163,6 +162,8 @@ pb_cache_manager_create(struct pb_manager *provider,
unsigned usecs);
struct pb_fence_ops;
/**
* Fenced buffer manager.
*
@ -174,7 +175,7 @@ pb_cache_manager_create(struct pb_manager *provider,
*/
struct pb_manager *
fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys);
struct pb_fence_ops *ops);
struct pb_manager *

View File

@ -122,7 +122,7 @@ fenced_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys)
struct pb_fence_ops *ops)
{
struct fenced_pb_manager *fenced_mgr;
@ -138,7 +138,7 @@ fenced_bufmgr_create(struct pb_manager *provider,
fenced_mgr->base.flush = fenced_bufmgr_flush;
fenced_mgr->provider = provider;
fenced_mgr->fenced_list = fenced_buffer_list_create(winsys);
fenced_mgr->fenced_list = fenced_buffer_list_create(ops);
if(!fenced_mgr->fenced_list) {
FREE(fenced_mgr);
return NULL;

View File

@ -114,7 +114,7 @@ tgsi_default_declaration( void )
struct tgsi_declaration declaration;
declaration.Type = TGSI_TOKEN_TYPE_DECLARATION;
declaration.Size = 1;
declaration.NrTokens = 1;
declaration.File = TGSI_FILE_NULL;
declaration.UsageMask = TGSI_WRITEMASK_XYZW;
declaration.Interpolate = TGSI_INTERPOLATE_CONSTANT;
@ -160,9 +160,9 @@ declaration_grow(
struct tgsi_declaration *declaration,
struct tgsi_header *header )
{
assert( declaration->Size < 0xFF );
assert( declaration->NrTokens < 0xFF );
declaration->Size++;
declaration->NrTokens++;
header_bodysize_grow( header );
}
@ -308,7 +308,7 @@ tgsi_default_immediate( void )
struct tgsi_immediate immediate;
immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
immediate.Size = 1;
immediate.NrTokens = 1;
immediate.DataType = TGSI_IMM_FLOAT32;
immediate.Padding = 0;
immediate.Extended = 0;
@ -345,9 +345,9 @@ immediate_grow(
struct tgsi_immediate *immediate,
struct tgsi_header *header )
{
assert( immediate->Size < 0xFF );
assert( immediate->NrTokens < 0xFF );
immediate->Size++;
immediate->NrTokens++;
header_bodysize_grow( header );
}
@ -384,7 +384,7 @@ tgsi_build_full_immediate(
*immediate = tgsi_build_immediate( header );
for( i = 0; i < full_imm->Immediate.Size - 1; i++ ) {
for( i = 0; i < full_imm->Immediate.NrTokens - 1; i++ ) {
struct tgsi_immediate_float32 *if32;
if( maxsize <= size )
@ -411,7 +411,7 @@ tgsi_default_instruction( void )
struct tgsi_instruction instruction;
instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
instruction.Size = 1;
instruction.NrTokens = 1;
instruction.Opcode = TGSI_OPCODE_MOV;
instruction.Saturate = TGSI_SAT_NONE;
instruction.NumDstRegs = 1;
@ -453,9 +453,9 @@ instruction_grow(
struct tgsi_instruction *instruction,
struct tgsi_header *header )
{
assert (instruction->Size < 0xFF);
assert (instruction->NrTokens < 0xFF);
instruction->Size++;
instruction->NrTokens++;
header_bodysize_grow( header );
}

View File

@ -285,7 +285,7 @@ iter_immediate(
ENM( imm->Immediate.DataType, immediate_type_names );
TXT( " { " );
for (i = 0; i < imm->Immediate.Size - 1; i++) {
for (i = 0; i < imm->Immediate.NrTokens - 1; i++) {
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
FLT( imm->u.ImmediateFloat32[i].Float );
@ -294,7 +294,7 @@ iter_immediate(
assert( 0 );
}
if (i < imm->Immediate.Size - 2)
if (i < imm->Immediate.NrTokens - 2)
TXT( ", " );
}
TXT( " }" );

View File

@ -283,7 +283,7 @@ dump_immediate_verbose(
UIX( imm->Immediate.Padding );
}
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
for( i = 0; i < imm->Immediate.NrTokens - 1; i++ ) {
EOL();
switch( imm->Immediate.DataType ) {
case TGSI_IMM_FLOAT32:
@ -675,7 +675,7 @@ tgsi_dump_c(
ENM( parse.FullToken.Token.Type, TGSI_TOKEN_TYPES );
if( ignored ) {
TXT( "\nSize : " );
UID( parse.FullToken.Token.Size );
UID( parse.FullToken.Token.NrTokens );
if( deflt || parse.FullToken.Token.Extended ) {
TXT( "\nExtended : " );
UID( parse.FullToken.Token.Extended );

View File

@ -202,7 +202,7 @@ tgsi_exec_machine_bind_shader(
case TGSI_TOKEN_TYPE_IMMEDIATE:
{
uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
assert( size % 4 == 0 );
assert( mach->ImmLimit + size / 4 <= TGSI_EXEC_NUM_IMMEDIATES );

View File

@ -155,8 +155,8 @@ tgsi_parse_token(
switch (imm->Immediate.DataType) {
case TGSI_IMM_FLOAT32:
imm->u.Pointer = MALLOC(
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.NrTokens - 1) );
for( i = 0; i < imm->Immediate.NrTokens - 1; i++ ) {
next_token( ctx, (struct tgsi_immediate_float32 *) &imm->u.ImmediateFloat32[i] );
}
break;

View File

@ -1327,7 +1327,7 @@ tgsi_emit_ppc(const struct tgsi_token *tokens,
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* splat each immediate component into a float[4] vector for SoA */
{
const uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
uint i;
assert(size <= 4);
assert(num_immediates < TGSI_EXEC_NUM_IMMEDIATES);

View File

@ -2671,7 +2671,7 @@ tgsi_emit_sse2(
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* simply copy the immediate values into the next immediates[] slot */
{
const uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
const uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
uint i;
assert(size <= 4);
assert(num_immediates < TGSI_EXEC_NUM_IMMEDIATES);

View File

@ -1023,7 +1023,7 @@ static boolean parse_immediate( struct translate_ctx *ctx )
ctx->cur++;
imm = tgsi_default_full_immediate();
imm.Immediate.Size += 4;
imm.Immediate.NrTokens += 4;
imm.Immediate.DataType = TGSI_IMM_FLOAT32;
imm.u.Pointer = values;

View File

@ -964,7 +964,7 @@ i915_translate_instructions(struct i915_fp_compile *p,
= &parse.FullToken.FullImmediate;
const uint pos = p->num_immediates++;
uint j;
for (j = 0; j < imm->Immediate.Size; j++) {
for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
p->immediates[pos][j] = imm->u.ImmediateFloat32[j].Float;
}
}

View File

@ -1293,7 +1293,7 @@ void brw_vs_emit(struct brw_vs_compile *c)
break;
case TGSI_TOKEN_TYPE_IMMEDIATE: {
struct tgsi_full_immediate *imm = &parse.FullToken.FullImmediate;
/*assert(imm->Immediate.Size == 4);*/
assert(imm->Immediate.NrTokens == 4 + 1);
c->prog_data.imm_buf[c->prog_data.num_imm][0] = imm->u.ImmediateFloat32[0].Float;
c->prog_data.imm_buf[c->prog_data.num_imm][1] = imm->u.ImmediateFloat32[1].Float;
c->prog_data.imm_buf[c->prog_data.num_imm][2] = imm->u.ImmediateFloat32[2].Float;

View File

@ -1,7 +1,6 @@
#include "pipe/p_context.h"
#include "pipe/p_format.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_util.h"
@ -106,9 +105,8 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
const unsigned max_h = 1024;
const unsigned sub_w = w > max_w ? max_w : w;
const unsigned sub_h = h > max_h ? max_h : h;
unsigned cx = 0;
unsigned cy = 0;
int i, offset = 0;
unsigned cx;
unsigned cy;
/* POT or GTFO */
assert(!(w & (w - 1)) && !(h & (h - 1)));
@ -116,54 +114,46 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
OUT_RELOCo(chan, dst_bo,
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1);
OUT_RING (chan, nv04_surface_format(dst->format) |
log2i(w) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
log2i(h) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
OUT_RELOCo(chan, src_bo,
NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
OUT_RING (chan, swzsurf->handle);
/* Upload, then swizzle each mipmap level in turn */
for (i=0; i<src->texture->last_level; i++) {
for (cy = 0; cy < h; cy += sub_h) {
for (cx = 0; cx < w; cx += sub_w) {
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(cx, cy) *
dst->block.size, NOUVEAU_BO_GART |
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
for (cy = 0; cy < h; cy += sub_h) {
for (cx = 0; cx < w; cx += sub_w) {
BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
OUT_RELOCl(chan, dst_bo, dst->offset + nv04_swizzle_bits(cx, cy) *
dst->block.size + offset, NOUVEAU_BO_GART |
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
OUT_RING (chan, nv04_scaled_image_format(src->format));
OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
OUT_RING (chan, 0);
OUT_RING (chan, sub_h << 16 | sub_w);
OUT_RING (chan, 0);
OUT_RING (chan, sub_h << 16 | sub_w);
OUT_RING (chan, 1 << 20);
OUT_RING (chan, 1 << 20);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
OUT_RING (chan, nv04_scaled_image_format(src->format));
OUT_RING (chan, NV04_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
OUT_RING (chan, 0);
OUT_RING (chan, sub_h << 16 | sub_w);
OUT_RING (chan, 0);
OUT_RING (chan, sub_h << 16 | sub_w);
OUT_RING (chan, 1 << 20);
OUT_RING (chan, 1 << 20);
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
OUT_RING (chan, sub_h << 16 | sub_w);
OUT_RING (chan, src->stride |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
OUT_RELOCl(chan, src_bo, src->offset + cy * src->stride +
cx * src->block.size + offset, NOUVEAU_BO_GART |
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RING (chan, 0);
}
}
/* FIXME: need to know how many bytes per pixel */
offset += align(w * h * 2 /*src->block.size*/, 64);
w >>= 1;
h >>= 1;
BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
OUT_RING (chan, sub_h << 16 | sub_w);
OUT_RING (chan, src->stride |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
NV04_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
OUT_RELOCl(chan, src_bo, src->offset + cy * src->stride +
cx * src->block.size, NOUVEAU_BO_GART |
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RING (chan, 0);
}
}
return 0;
@ -258,8 +248,7 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
assert(src->format == dst->format);
/* Setup transfer to swizzle the texture to vram if needed */
/* FIXME/TODO: check proper limits of this operation */
if (src_linear ^ dst_linear) {
if (src_linear && !dst_linear && w > 1 && h > 1) {
nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h);
return;
}
@ -267,7 +256,8 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
/* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
* to NV_MEMORY_TO_MEMORY_FORMAT in this case.
*/
if ((src->offset & 63) || (dst->offset & 63)) {
if ((src->offset & 63) || (dst->offset & 63) ||
(src->stride & 63) || (dst->stride & 63)) {
nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h);
return;
}
@ -456,5 +446,3 @@ nv04_surface_2d_init(struct nouveau_winsys *nvws)
ctx->fill = nv04_surface_fill;
return ctx;
}

View File

@ -613,7 +613,7 @@ nv20_vertprog_translate(struct nv20_context *nv20,
imm = &parse.FullToken.FullImmediate;
assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
// assert(imm->Immediate.Size == 4);
assert(imm->Immediate.NrTokens == 4 + 1);
vpc->imm[vpc->nr_imm++] =
constant(vpc, -1,
imm->u.ImmediateFloat32[0].Float,

View File

@ -8,10 +8,14 @@ static void
nv30_miptree_layout(struct nv30_miptree *nv30mt)
{
struct pipe_texture *pt = &nv30mt->base;
boolean swizzled = FALSE;
uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
uint offset = 0;
int nr_faces, l, f, pitch;
int nr_faces, l, f;
uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
PIPE_TEXTURE_USAGE_PRIMARY);
if (pt->target == PIPE_TEXTURE_CUBE) {
nr_faces = 6;
@ -22,7 +26,6 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
nr_faces = 1;
}
pitch = pt->width[0];
for (l = 0; l <= pt->last_level; l++) {
pt->width[l] = width;
pt->height[l] = height;
@ -30,11 +33,11 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
if (swizzled)
pitch = pt->nblocksx[l];
pitch = align(pitch, 64);
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
nv30mt->level[l].pitch = align(pt->width[0] * pt->block.size, 64);
else
nv30mt->level[l].pitch = pt->width[l] * pt->block.size;
nv30mt->level[l].pitch = pitch * pt->block.size;
nv30mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
@ -44,10 +47,17 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
}
for (f = 0; f < nr_faces; f++) {
for (l = 0; l <= pt->last_level; l++) {
for (l = 0; l < pt->last_level; l++) {
nv30mt->level[l].image_offset[f] = offset;
offset += nv30mt->level[l].pitch * pt->height[l];
if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
offset += align(nv30mt->level[l].pitch * pt->height[l], 64);
else
offset += nv30mt->level[l].pitch * pt->height[l];
}
nv30mt->level[l].image_offset[f] = offset;
offset += nv30mt->level[l].pitch * pt->height[l];
}
nv30mt->total_size = offset;
@ -74,7 +84,8 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
else
if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
PIPE_TEXTURE_USAGE_DISPLAY_TARGET))
+ PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
else
if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
@ -85,7 +96,11 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_X8R8G8B8_UNORM:
case PIPE_FORMAT_R16_SNORM:
break;
{
if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
break;
}
default:
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
}
@ -148,8 +163,8 @@ nv30_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
}
if (mt->shadow_tex) {
assert(mt->shadow_surface);
pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
if (mt->shadow_surface)
pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
nv30_miptree_release(pscreen, &mt->shadow_tex);
}

View File

@ -206,6 +206,8 @@ nv30_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
nvscreen->eng2d->copy(nvscreen->eng2d, surface, 0, 0,
surface_to_unmap, 0, 0,
surface->width, surface->height);
screen->tex_surface_release(screen, &surface_to_unmap);
}
}

View File

@ -613,7 +613,7 @@ nv30_vertprog_translate(struct nv30_context *nv30,
imm = &parse.FullToken.FullImmediate;
assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
// assert(imm->Immediate.Size == 4);
assert(imm->Immediate.NrTokens == 4 + 1);
vpc->imm[vpc->nr_imm++] =
constant(vpc, -1,
imm->u.ImmediateFloat32[0].Float,

View File

@ -10,7 +10,12 @@ nv40_miptree_layout(struct nv40_miptree *mt)
struct pipe_texture *pt = &mt->base;
uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
uint offset = 0;
int nr_faces, l, f, pitch;
int nr_faces, l, f;
uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
PIPE_TEXTURE_USAGE_PRIMARY);
if (pt->target == PIPE_TEXTURE_CUBE) {
nr_faces = 6;
@ -21,7 +26,6 @@ nv40_miptree_layout(struct nv40_miptree *mt)
nr_faces = 1;
}
pitch = pt->width[0];
for (l = 0; l <= pt->last_level; l++) {
pt->width[l] = width;
pt->height[l] = height;
@ -29,11 +33,11 @@ nv40_miptree_layout(struct nv40_miptree *mt)
pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
pitch = pt->nblocksx[l];
pitch = align(pitch, 64);
if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
mt->level[l].pitch = align(pt->width[0] * pt->block.size, 64);
else
mt->level[l].pitch = pt->width[l] * pt->block.size;
mt->level[l].pitch = pitch * pt->block.size;
mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
@ -43,10 +47,17 @@ nv40_miptree_layout(struct nv40_miptree *mt)
}
for (f = 0; f < nr_faces; f++) {
for (l = 0; l <= pt->last_level; l++) {
for (l = 0; l < pt->last_level; l++) {
mt->level[l].image_offset[f] = offset;
offset += mt->level[l].pitch * pt->height[l];
if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
offset += align(mt->level[l].pitch * pt->height[l], 64);
else
offset += mt->level[l].pitch * pt->height[l];
}
mt->level[l].image_offset[f] = offset;
offset += mt->level[l].pitch * pt->height[l];
}
mt->total_size = offset;
@ -75,7 +86,8 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
else
if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
PIPE_TEXTURE_USAGE_DISPLAY_TARGET))
PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
else
if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
@ -86,7 +98,11 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_X8R8G8B8_UNORM:
case PIPE_FORMAT_R16_SNORM:
{
if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
break;
}
default:
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
}
@ -149,8 +165,8 @@ nv40_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
}
if (mt->shadow_tex) {
assert(mt->shadow_surface);
pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
if (mt->shadow_surface)
pscreen->tex_surface_release(pscreen, &mt->shadow_surface);
nv40_miptree_release(pscreen, &mt->shadow_tex);
}

View File

@ -214,6 +214,8 @@ nv40_surface_unmap(struct pipe_screen *screen, struct pipe_surface *surface)
nvscreen->eng2d->copy(nvscreen->eng2d, surface, 0, 0,
surface_to_unmap, 0, 0,
surface->width, surface->height);
screen->tex_surface_release(screen, &surface_to_unmap);
}
}

View File

@ -784,7 +784,7 @@ nv40_vertprog_translate(struct nv40_context *nv40,
imm = &parse.FullToken.FullImmediate;
assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
// assert(imm->Immediate.Size == 4);
assert(imm->Immediate.NrTokens == 4 + 1);
vpc->imm[vpc->nr_imm++] =
constant(vpc, -1,
imm->u.ImmediateFloat32[0].Float,

View File

@ -64,7 +64,7 @@ struct tgsi_processor
struct tgsi_token
{
unsigned Type : 4; /**< TGSI_TOKEN_TYPE_x */
unsigned Size : 8; /**< UINT */
unsigned NrTokens : 8; /**< UINT */
unsigned Padding : 19;
unsigned Extended : 1; /**< BOOL */
};
@ -107,7 +107,7 @@ enum tgsi_file_type {
struct tgsi_declaration
{
unsigned Type : 4; /**< TGSI_TOKEN_TYPE_DECLARATION */
unsigned Size : 8; /**< UINT */
unsigned NrTokens : 8; /**< UINT */
unsigned File : 4; /**< one of TGSI_FILE_x */
unsigned UsageMask : 4; /**< bitmask of TGSI_WRITEMASK_x flags */
unsigned Interpolate : 4; /**< one of TGSI_INTERPOLATE_x */
@ -145,7 +145,7 @@ struct tgsi_declaration_semantic
struct tgsi_immediate
{
unsigned Type : 4; /**< TGSI_TOKEN_TYPE_IMMEDIATE */
unsigned Size : 8; /**< UINT */
unsigned NrTokens : 8; /**< UINT */
unsigned DataType : 4; /**< one of TGSI_IMM_x */
unsigned Padding : 15;
unsigned Extended : 1; /**< BOOL */
@ -442,7 +442,7 @@ struct tgsi_immediate_float32
struct tgsi_instruction
{
unsigned Type : 4; /* TGSI_TOKEN_TYPE_INSTRUCTION */
unsigned Size : 8; /* UINT */
unsigned NrTokens : 8; /* UINT */
unsigned Opcode : 8; /* TGSI_OPCODE_ */
unsigned Saturate : 2; /* TGSI_SAT_ */
unsigned NumDstRegs : 2; /* UINT */
@ -458,7 +458,7 @@ struct tgsi_instruction
*
* Then, tgsi_instruction::NumSrcRegs of tgsi_src_register follow.
*
* tgsi_instruction::Size contains the total number of words that make the
* tgsi_instruction::NrTokens contains the total number of words that make the
* instruction, including the instruction word.
*/

View File

@ -31,6 +31,7 @@
#include "GL/gl.h"
#include "pipe/p_debug.h"
#include "pipe/p_thread.h"
#include "shared/stw_public.h"
#include "icd/stw_icd.h"
@ -41,11 +42,14 @@
struct stw_icd
{
pipe_mutex mutex;
GLCLTPROCTABLE cpt;
boolean cpt_initialized;
struct {
struct stw_context *ctx;
} ctx_array[DRV_CONTEXT_MAX];
DHGLRC ctx_current;
};
@ -62,6 +66,8 @@ stw_icd_init( void )
stw_icd = &stw_icd_storage;
memset(stw_icd, 0, sizeof *stw_icd);
pipe_mutex_init( stw_icd->mutex );
return TRUE;
}
@ -70,26 +76,35 @@ stw_icd_cleanup(void)
{
int i;
if(!stw_icd)
if (!stw_icd)
return;
pipe_mutex_lock( stw_icd->mutex );
{
/* Ensure all contexts are destroyed */
for (i = 0; i < DRV_CONTEXT_MAX; i++)
if (stw_icd->ctx_array[i].ctx)
stw_delete_context( stw_icd->ctx_array[i].ctx );
}
pipe_mutex_unlock( stw_icd->mutex );
/* Ensure all contexts are destroyed */
for (i = 0; i < DRV_CONTEXT_MAX; i++)
if (stw_icd->ctx_array[i].ctx)
stw_delete_context( stw_icd->ctx_array[i].ctx );
pipe_mutex_init( stw_icd->mutex );
stw_icd = NULL;
}
static struct stw_context *
lookup_context( DHGLRC dhglrc )
lookup_context( struct stw_icd *icd,
DHGLRC dhglrc )
{
if (dhglrc == 0 ||
dhglrc >= DRV_CONTEXT_MAX)
return NULL;
return stw_icd->ctx_array[dhglrc - 1].ctx;
if (icd == NULL)
return NULL;
return icd->ctx_array[dhglrc - 1].ctx;
}
BOOL APIENTRY
@ -98,14 +113,25 @@ DrvCopyContext(
DHGLRC dhrcDest,
UINT fuMask )
{
struct stw_context *src = lookup_context( dhrcSource );
struct stw_context *dst = lookup_context( dhrcDest );
if (src == NULL ||
dst == NULL)
BOOL ret = FALSE;
if (!stw_icd)
return FALSE;
return stw_copy_context( src, dst, fuMask );
pipe_mutex_lock( stw_icd->mutex );
{
struct stw_context *src = lookup_context( stw_icd, dhrcSource );
struct stw_context *dst = lookup_context( stw_icd, dhrcDest );
if (src == NULL || dst == NULL)
goto done;
ret = stw_copy_context( src, dst, fuMask );
}
done:
pipe_mutex_unlock( stw_icd->mutex );
return ret;
}
DHGLRC APIENTRY
@ -113,23 +139,37 @@ DrvCreateLayerContext(
HDC hdc,
INT iLayerPlane )
{
DWORD i;
DHGLRC handle = 0;
if (!stw_icd)
return handle;
pipe_mutex_lock( stw_icd->mutex );
{
int i;
for (i = 0; i < DRV_CONTEXT_MAX; i++) {
if (stw_icd->ctx_array[i].ctx == NULL)
break;
}
for (i = 0; i < DRV_CONTEXT_MAX; i++) {
if (stw_icd->ctx_array[i].ctx == NULL)
goto found_slot;
/* No slot available, fail:
*/
if (i == DRV_CONTEXT_MAX)
goto done;
stw_icd->ctx_array[i].ctx = stw_create_context( hdc, iLayerPlane );
if (stw_icd->ctx_array[i].ctx == NULL)
goto done;
/* success:
*/
handle = (DHGLRC) i + 1;
}
/* No slot available, fail:
*/
return 0;
done:
pipe_mutex_unlock( stw_icd->mutex );
found_slot:
stw_icd->ctx_array[i].ctx = stw_create_context( hdc, iLayerPlane );
if (stw_icd->ctx_array[i].ctx == NULL)
return 0;
return (DHGLRC) i + 1;
return handle;
}
DHGLRC APIENTRY
@ -143,20 +183,30 @@ BOOL APIENTRY
DrvDeleteContext(
DHGLRC dhglrc )
{
struct stw_context *ctx;
BOOL ret = FALSE;
ctx = lookup_context( dhglrc );
if (ctx == NULL)
goto fail;
if (!stw_icd)
return ret;
if (stw_delete_context( ctx ) == FALSE)
goto fail;
pipe_mutex_lock( stw_icd->mutex );
{
struct stw_context *ctx;
stw_icd->ctx_array[dhglrc - 1].ctx = NULL;
return TRUE;
ctx = lookup_context( stw_icd, dhglrc );
if (ctx == NULL)
goto done;
if (stw_delete_context( ctx ) == FALSE)
goto done;
stw_icd->ctx_array[dhglrc - 1].ctx = NULL;
ret = TRUE;
}
done:
pipe_mutex_unlock( stw_icd->mutex );
fail:
return FALSE;
return ret;
}
BOOL APIENTRY
@ -183,7 +233,7 @@ DrvDescribePixelFormat(
r = stw_pixelformat_describe( hdc, iPixelFormat, cjpfd, ppfd );
debug_printf( "%s( 0x%p, %d, %u, 0x%p ) = %d\n",
debug_printf( "%s( %p, %d, %u, %p ) = %d\n",
__FUNCTION__, hdc, iPixelFormat, cjpfd, ppfd, r );
return r;
@ -210,7 +260,7 @@ DrvGetProcAddress(
r = stw_get_proc_address( lpszProc );
debug_printf( "%s( \", __FUNCTION__%s\" ) = 0x%p\n", lpszProc, r );
debug_printf( "%s( \", __FUNCTION__%s\" ) = %p\n", lpszProc, r );
return r;
}
@ -230,23 +280,32 @@ BOOL APIENTRY
DrvReleaseContext(
DHGLRC dhglrc )
{
struct stw_context *ctx;
BOOL ret = FALSE;
if (dhglrc != stw_icd->ctx_current)
goto fail;
if (!stw_icd)
return ret;
ctx = lookup_context( dhglrc );
if (ctx == NULL)
goto fail;
pipe_mutex_lock( stw_icd->mutex );
{
struct stw_context *ctx;
if (stw_make_current( NULL, NULL ) == FALSE)
goto fail;
/* XXX: The expectation is that ctx is the same context which is
* current for this thread. We should check that and return False
* if not the case.
*/
ctx = lookup_context( stw_icd, dhglrc );
if (ctx == NULL)
goto done;
stw_icd->ctx_current = 0;
return TRUE;
if (stw_make_current( NULL, NULL ) == FALSE)
goto done;
fail:
return FALSE;
ret = TRUE;
}
done:
pipe_mutex_unlock( stw_icd->mutex );
return ret;
}
void APIENTRY
@ -254,36 +313,20 @@ DrvSetCallbackProcs(
INT nProcs,
PROC *pProcs )
{
debug_printf( "%s( %d, 0x%p )\n", __FUNCTION__, nProcs, pProcs );
debug_printf( "%s( %d, %p )\n", __FUNCTION__, nProcs, pProcs );
return;
}
static void init_proc_table( GLCLTPROCTABLE *cpt )
{
GLDISPATCHTABLE *disp = &cpt->glDispatchTable;
memset( cpt, 0, sizeof *cpt );
cpt->cEntries = OPENGL_VERSION_110_ENTRIES;
#define GPA_GL( NAME ) disp->NAME = gl##NAME
static GLCLTPROCTABLE cpt;
PGLCLTPROCTABLE APIENTRY
DrvSetContext(
HDC hdc,
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
struct stw_context *ctx;
GLDISPATCHTABLE *disp = &cpt.glDispatchTable;
debug_printf( "%s( 0x%p, %u, 0x%p )\n", __FUNCTION__, hdc, dhglrc, pfnSetProcTable );
ctx = lookup_context( dhglrc );
if (ctx == NULL)
return NULL;
if (!stw_make_current( hdc, ctx ))
return NULL;
memset( &cpt, 0, sizeof( cpt ) );
cpt.cEntries = OPENGL_VERSION_110_ENTRIES;
GPA_GL( NewList );
GPA_GL( EndList );
GPA_GL( CallList );
@ -620,8 +663,46 @@ DrvSetContext(
GPA_GL( TexSubImage2D );
GPA_GL( PopClientAttrib );
GPA_GL( PushClientAttrib );
}
return &cpt;
PGLCLTPROCTABLE APIENTRY
DrvSetContext(
HDC hdc,
DHGLRC dhglrc,
PFN_SETPROCTABLE pfnSetProcTable )
{
PGLCLTPROCTABLE result = NULL;
if (!stw_icd)
return result;
pipe_mutex_lock( stw_icd->mutex );
{
struct stw_context *ctx;
debug_printf( "%s( 0x%p, %u, 0x%p )\n",
__FUNCTION__, hdc, dhglrc, pfnSetProcTable );
/* Although WGL allows different dispatch entrypoints per
*/
if (!stw_icd->cpt_initialized) {
init_proc_table( &stw_icd->cpt );
stw_icd->cpt_initialized = TRUE;
}
ctx = lookup_context( stw_icd, dhglrc );
if (ctx == NULL)
goto done;
if (!stw_make_current( hdc, ctx ))
goto done;
result = &stw_icd->cpt;
}
done:
pipe_mutex_unlock( stw_icd->mutex );
return result;
}
int APIENTRY
@ -646,7 +727,7 @@ DrvSetPixelFormat(
r = stw_pixelformat_set( hdc, iPixelFormat );
debug_printf( "%s( 0x%p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
debug_printf( "%s( %p, %d ) = %s\n", __FUNCTION__, hdc, iPixelFormat, r ? "TRUE" : "FALSE" );
return r;
}
@ -665,7 +746,7 @@ BOOL APIENTRY
DrvSwapBuffers(
HDC hdc )
{
debug_printf( "%s( 0x%p )\n", __FUNCTION__, hdc );
debug_printf( "%s( %p )\n", __FUNCTION__, hdc );
return stw_swap_buffers( hdc );
}
@ -686,5 +767,7 @@ DrvValidateVersion(
{
debug_printf( "%s( %u )\n", __FUNCTION__, ulVersion );
/* TODO: get the expected version from the winsys */
return ulVersion == 1;
}

View File

@ -256,6 +256,14 @@ stw_pixelformat_set(
return FALSE;
currentpixelformat = iPixelFormat;
/* Some applications mistakenly use the undocumented wglSetPixelFormat
* function instead of SetPixelFormat, so we call SetPixelFormat here to
* avoid opengl32.dll's wglCreateContext to fail */
if (GetPixelFormat(hdc) == 0) {
SetPixelFormat(hdc, iPixelFormat, NULL);
}
return TRUE;
}

View File

@ -10,7 +10,6 @@ target = 'glut32'
env.Replace(CPPDEFINES = [
'BUILD_GLUT32',
'GLUT_BUILDING_LIB',
'MESA',
'NDEBUG',
'GLUT_NO_WARNING_DISABLE',
])

View File

@ -1,9 +1,4 @@
DESCRIPTION 'OpenGL Utility Toolkit for Win32'
VERSION 3.7
EXPORTS
glutAddMenuEntry
glutAddSubMenu
glutAttachMenu
@ -128,4 +123,3 @@ EXPORTS
glutBitmapTimesRoman24
; __glutSetFCB
; __glutGetFCB

View File

@ -32,10 +32,6 @@
#include <GL/glut.h>
#if defined(MESA) && defined(_WIN32) && !defined(__CYGWIN32__)
#include <GL/mesa_wgl.h>
#endif
#ifndef _WIN32
/* added by BrianP: */
#ifndef APIENTRY
@ -48,24 +44,6 @@
/* GLUT_BUILDING_LIB is used by <GL/glut.h> to 1) not #pragma link
with the GLUT library, and 2) avoid the Win32 atexit hack. */
/* This must be done after <GL/gl.h> is included. MESA is defined
if the <GL/gl.h> is supplied by Brian Paul's Mesa library. */
#if defined(MESA) && defined(_WIN32)
/* Mesa implements "wgl" versions of GDI entry points needed for
using OpenGL. Map these "wgl" versions to the GDI names via
macros. */
#define ChoosePixelFormat wglChoosePixelFormat
#define DescribePixelFormat wglDescribePixelFormat
#define GetPixelFormat wglGetPixelFormat
#define SetPixelFormat wglSetPixelFormat
#define SwapBuffers wglSwapBuffers
#define GetCurrentContext wglGetCurrentContext
#define GetCurrentDC wglGetCurrentDC
#define MakeCurrent wglMakeCurrent
#define CreateContext wglCreateContext
#define DeleteContext wglDeleteContext
#endif /* MESA */
#ifdef SUPPORT_FORTRAN
#include <GL/glutf90.h>
#endif
@ -572,27 +550,27 @@ typedef struct {
#ifdef _WIN32
#define MAKE_CURRENT_LAYER(window) \
{ \
HGLRC currentContext = GetCurrentContext(); \
HDC currentDc = GetCurrentDC(); \
HGLRC currentContext = wglGetCurrentContext(); \
HDC currentDc = wglGetCurrentDC(); \
\
if (currentContext != window->renderCtx \
|| currentDc != window->renderDc) { \
MakeCurrent(window->renderDc, window->renderCtx); \
wglMakeCurrent(window->renderDc, window->renderCtx); \
} \
}
#define MAKE_CURRENT_WINDOW(window) \
{ \
HGLRC currentContext = GetCurrentContext(); \
HDC currentDc = GetCurrentDC(); \
HGLRC currentContext = wglGetCurrentContext(); \
HDC currentDc = wglGetCurrentDC(); \
\
if (currentContext != window->ctx || currentDc != window->hdc) { \
MakeCurrent(window->hdc, window->ctx); \
wglMakeCurrent(window->hdc, window->ctx); \
} \
}
#define MAKE_CURRENT_OVERLAY(overlay) \
MakeCurrent(overlay->hdc, overlay->ctx)
wglMakeCurrent(overlay->hdc, overlay->ctx)
#define UNMAKE_CURRENT() \
MakeCurrent(NULL, NULL)
wglMakeCurrent(NULL, NULL)
#define SWAP_BUFFERS_WINDOW(window) \
SwapBuffers(window->hdc)
#define SWAP_BUFFERS_LAYER(window) \

View File

@ -22,7 +22,7 @@ glXCreateContext(Display * display, XVisualInfo * visinfo,
routine. */
HGLRC context;
context = CreateContext(XHDC);
context = wglCreateContext(XHDC);
#if 0
/* XXX GLUT doesn't support it now, so don't worry about display list

View File

@ -1223,11 +1223,11 @@ static void store_texel_srgb8(struct gl_texture_image *texImage,
static void FETCH(srgba8)(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
texel[RCOMP] = nonlinear_to_linear(src[0]);
texel[GCOMP] = nonlinear_to_linear(src[1]);
texel[BCOMP] = nonlinear_to_linear(src[2]);
texel[ACOMP] = UBYTE_TO_FLOAT(src[3]); /* linear! */
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
texel[BCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff ); /* linear! */
}
#if DIM == 3
@ -1235,11 +1235,8 @@ static void store_texel_srgba8(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
dst[0] = rgba[RCOMP];
dst[1] = rgba[GCOMP];
dst[2] = rgba[BCOMP];
dst[3] = rgba[ACOMP];
GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
*dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
}
#endif
@ -1247,11 +1244,11 @@ static void store_texel_srgba8(struct gl_texture_image *texImage,
static void FETCH(sargb8)(const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
texel[RCOMP] = nonlinear_to_linear(src[1]);
texel[GCOMP] = nonlinear_to_linear(src[2]);
texel[BCOMP] = nonlinear_to_linear(src[3]);
texel[ACOMP] = UBYTE_TO_FLOAT(src[0]); /* linear! */
const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
texel[RCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
texel[GCOMP] = nonlinear_to_linear( (s >> 8) & 0xff );
texel[BCOMP] = nonlinear_to_linear( (s ) & 0xff );
texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) ); /* linear! */
}
#if DIM == 3
@ -1259,11 +1256,8 @@ static void store_texel_sargb8(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLubyte *rgba = (const GLubyte *) texel;
GLubyte *dst = TEXEL_ADDR(GLubyte, texImage, i, j, k, 4);
dst[0] = rgba[ACOMP];
dst[1] = rgba[RCOMP];
dst[2] = rgba[GCOMP];
dst[3] = rgba[BCOMP];
GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
*dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
}
#endif

View File

@ -3699,14 +3699,37 @@ is_srgb_teximage(const struct gl_texture_image *texImage)
case MESA_FORMAT_SARGB8:
case MESA_FORMAT_SL8:
case MESA_FORMAT_SLA8:
case MESA_FORMAT_SRGB_DXT1:
case MESA_FORMAT_SRGBA_DXT1:
case MESA_FORMAT_SRGBA_DXT3:
case MESA_FORMAT_SRGBA_DXT5:
return GL_TRUE;
default:
return GL_FALSE;
}
}
#endif /* FEATURE_EXT_texture_sRGB */
/**
* Convert a float value from linear space to a
* non-linear sRGB value in [0, 255].
* Not terribly efficient.
*/
static INLINE GLfloat
linear_to_nonlinear(GLfloat cl)
{
/* can't have values outside [0, 1] */
GLfloat cs;
if (cl < 0.0031308) {
cs = 12.92 * cl;
}
else {
cs = 1.055 * _mesa_pow(cl, 0.41666) - 0.055;
}
return cs;
}
#endif /* FEATURE_EXT_texture_sRGB */
/**
* This is the software fallback for Driver.GetTexImage().
@ -3823,16 +3846,34 @@ _mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
}
#if FEATURE_EXT_texture_sRGB
else if (is_srgb_teximage(texImage)) {
/* no pixel transfer and no non-linear to linear conversion */
const GLint comps = texImage->TexFormat->TexelBytes;
const GLint rowstride = comps * texImage->RowStride;
MEMCPY(dest,
(const GLubyte *) texImage->Data + row * rowstride,
comps * width * sizeof(GLubyte));
/* FIXME: isn't it necessary to still do component assigning
according to format/type? */
/* FIXME: need to do something else for compressed srgb textures
(currently will return values converted to linear) */
/* special case this since need to backconvert values */
/* convert row to RGBA format */
GLfloat rgba[MAX_WIDTH][4];
GLint col;
GLbitfield transferOps = 0x0;
for (col = 0; col < width; col++) {
(*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
if (texImage->TexFormat->BaseFormat == GL_LUMINANCE) {
rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
rgba[col][GCOMP] = 0.0;
rgba[col][BCOMP] = 0.0;
}
else if (texImage->TexFormat->BaseFormat == GL_LUMINANCE_ALPHA) {
rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
rgba[col][GCOMP] = 0.0;
rgba[col][BCOMP] = 0.0;
}
else if (texImage->TexFormat->BaseFormat == GL_RGB ||
texImage->TexFormat->BaseFormat == GL_RGBA) {
rgba[col][RCOMP] = linear_to_nonlinear(rgba[col][RCOMP]);
rgba[col][GCOMP] = linear_to_nonlinear(rgba[col][GCOMP]);
rgba[col][BCOMP] = linear_to_nonlinear(rgba[col][BCOMP]);
}
}
_mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba,
format, type, dest,
&ctx->Pack, transferOps /*image xfer ops*/);
}
#endif /* FEATURE_EXT_texture_sRGB */
else {

View File

@ -1417,9 +1417,7 @@ st_finalize_texture(GLcontext *ctx,
stObj->pt->width[0] != firstImage->base.Width2 ||
stObj->pt->height[0] != firstImage->base.Height2 ||
stObj->pt->depth[0] != firstImage->base.Depth2 ||
stObj->pt->block.size != cpp ||
stObj->pt->block.width != 1 ||
stObj->pt->block.height != 1 ||
stObj->pt->block.size/stObj->pt->block.width != cpp || /* Nominal bytes per pixel */
stObj->pt->compressed != firstImage->base.IsCompressed) {
pipe_texture_release(&stObj->pt);
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;

View File

@ -188,7 +188,7 @@ make_immediate(const float *value, uint size)
struct tgsi_full_immediate imm;
imm = tgsi_default_full_immediate();
imm.Immediate.Size += size;
imm.Immediate.NrTokens += size;
imm.Immediate.DataType = TGSI_IMM_FLOAT32;
imm.u.Pointer = value;
return imm;