gallium: introduce 'pipe_screen' for context-independent functions
This will allow creating textures before a rendering context exists, for example. Only implemented in i915 driver for now. i915pipe->texture_create() just dispatches through to the i915screen->texture_create() to avoid state tracker changes for now.
This commit is contained in:
@@ -17,6 +17,7 @@ C_SOURCES = \
|
|||||||
i915_state_derived.c \
|
i915_state_derived.c \
|
||||||
i915_state_emit.c \
|
i915_state_emit.c \
|
||||||
i915_state_sampler.c \
|
i915_state_sampler.c \
|
||||||
|
i915_screen.c \
|
||||||
i915_strings.c \
|
i915_strings.c \
|
||||||
i915_prim_emit.c \
|
i915_prim_emit.c \
|
||||||
i915_prim_vbuf.c \
|
i915_prim_vbuf.c \
|
||||||
|
@@ -234,33 +234,11 @@ static boolean i915_draw_arrays( struct pipe_context *pipe,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
|
struct pipe_context *i915_create_context( struct pipe_screen *screen,
|
||||||
struct i915_winsys *i915_winsys,
|
struct pipe_winsys *pipe_winsys,
|
||||||
unsigned pci_id )
|
struct i915_winsys *i915_winsys )
|
||||||
{
|
{
|
||||||
struct i915_context *i915;
|
struct i915_context *i915;
|
||||||
unsigned is_i945 = 0;
|
|
||||||
|
|
||||||
switch (pci_id) {
|
|
||||||
case PCI_CHIP_I915_G:
|
|
||||||
case PCI_CHIP_I915_GM:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PCI_CHIP_I945_G:
|
|
||||||
case PCI_CHIP_I945_GM:
|
|
||||||
case PCI_CHIP_I945_GME:
|
|
||||||
case PCI_CHIP_G33_G:
|
|
||||||
case PCI_CHIP_Q33_G:
|
|
||||||
case PCI_CHIP_Q35_G:
|
|
||||||
is_i945 = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
pipe_winsys->printf(pipe_winsys,
|
|
||||||
"%s: unknown pci id 0x%x, cannot create context\n",
|
|
||||||
__FUNCTION__, pci_id);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
i915 = CALLOC_STRUCT(i915_context);
|
i915 = CALLOC_STRUCT(i915_context);
|
||||||
if (i915 == NULL)
|
if (i915 == NULL)
|
||||||
@@ -268,6 +246,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
|
|||||||
|
|
||||||
i915->winsys = i915_winsys;
|
i915->winsys = i915_winsys;
|
||||||
i915->pipe.winsys = pipe_winsys;
|
i915->pipe.winsys = pipe_winsys;
|
||||||
|
i915->pipe.screen = screen;
|
||||||
|
|
||||||
i915->pipe.destroy = i915_destroy;
|
i915->pipe.destroy = i915_destroy;
|
||||||
i915->pipe.is_format_supported = i915_is_format_supported;
|
i915->pipe.is_format_supported = i915_is_format_supported;
|
||||||
@@ -301,9 +280,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
|
|||||||
draw_install_aaline_stage(i915->draw, &i915->pipe);
|
draw_install_aaline_stage(i915->draw, &i915->pipe);
|
||||||
draw_install_aapoint_stage(i915->draw, &i915->pipe);
|
draw_install_aapoint_stage(i915->draw, &i915->pipe);
|
||||||
|
|
||||||
i915->pci_id = pci_id;
|
|
||||||
i915->flags.is_i945 = is_i945;
|
|
||||||
|
|
||||||
i915->dirty = ~0;
|
i915->dirty = ~0;
|
||||||
i915->hardware_dirty = ~0;
|
i915->hardware_dirty = ~0;
|
||||||
|
|
||||||
|
@@ -245,11 +245,6 @@ struct i915_context
|
|||||||
unsigned hardware_dirty;
|
unsigned hardware_dirty;
|
||||||
|
|
||||||
unsigned debug;
|
unsigned debug;
|
||||||
unsigned pci_id;
|
|
||||||
|
|
||||||
struct {
|
|
||||||
unsigned is_i945:1;
|
|
||||||
} flags;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A flag for each state_tracker state object:
|
/* A flag for each state_tracker state object:
|
||||||
@@ -322,6 +317,8 @@ void i915_init_surface_functions( struct i915_context *i915 );
|
|||||||
void i915_init_state_functions( struct i915_context *i915 );
|
void i915_init_state_functions( struct i915_context *i915 );
|
||||||
void i915_init_flush_functions( struct i915_context *i915 );
|
void i915_init_flush_functions( struct i915_context *i915 );
|
||||||
void i915_init_string_functions( struct i915_context *i915 );
|
void i915_init_string_functions( struct i915_context *i915 );
|
||||||
|
void i915_init_screen_string_functions(struct pipe_screen *screen);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
139
src/gallium/drivers/i915simple/i915_screen.c
Normal file
139
src/gallium/drivers/i915simple/i915_screen.c
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sub license, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the
|
||||||
|
* next paragraph) shall be included in all copies or substantial portions
|
||||||
|
* of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||||
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#include "pipe/p_util.h"
|
||||||
|
#include "pipe/p_winsys.h"
|
||||||
|
|
||||||
|
#include "i915_reg.h"
|
||||||
|
#include "i915_screen.h"
|
||||||
|
#include "i915_texture.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
i915_get_vendor( struct pipe_screen *pscreen )
|
||||||
|
{
|
||||||
|
return "Tungsten Graphics, Inc.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
i915_get_name( struct pipe_screen *pscreen )
|
||||||
|
{
|
||||||
|
static char buffer[128];
|
||||||
|
const char *chipset;
|
||||||
|
|
||||||
|
switch (i915_screen(pscreen)->pci_id) {
|
||||||
|
case PCI_CHIP_I915_G:
|
||||||
|
chipset = "915G";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_I915_GM:
|
||||||
|
chipset = "915GM";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_I945_G:
|
||||||
|
chipset = "945G";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_I945_GM:
|
||||||
|
chipset = "945GM";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_I945_GME:
|
||||||
|
chipset = "945GME";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_G33_G:
|
||||||
|
chipset = "G33";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_Q35_G:
|
||||||
|
chipset = "Q35";
|
||||||
|
break;
|
||||||
|
case PCI_CHIP_Q33_G:
|
||||||
|
chipset = "Q33";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
chipset = "unknown";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(buffer, "i915 (chipset: %s)", chipset);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
i915_destroy_screen( struct pipe_screen *screen )
|
||||||
|
{
|
||||||
|
FREE(screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new i915_screen object
|
||||||
|
*/
|
||||||
|
struct pipe_screen *
|
||||||
|
i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
|
||||||
|
{
|
||||||
|
struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen);
|
||||||
|
|
||||||
|
if (!i915screen)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
switch (pci_id) {
|
||||||
|
case PCI_CHIP_I915_G:
|
||||||
|
case PCI_CHIP_I915_GM:
|
||||||
|
i915screen->is_i945 = FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PCI_CHIP_I945_G:
|
||||||
|
case PCI_CHIP_I945_GM:
|
||||||
|
case PCI_CHIP_I945_GME:
|
||||||
|
case PCI_CHIP_G33_G:
|
||||||
|
case PCI_CHIP_Q33_G:
|
||||||
|
case PCI_CHIP_Q35_G:
|
||||||
|
i915screen->is_i945 = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
winsys->printf(winsys,
|
||||||
|
"%s: unknown pci id 0x%x, cannot create screen\n",
|
||||||
|
__FUNCTION__, pci_id);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
i915screen->pci_id = pci_id;
|
||||||
|
|
||||||
|
i915screen->screen.winsys = winsys;
|
||||||
|
|
||||||
|
i915screen->screen.destroy = i915_destroy_screen;
|
||||||
|
|
||||||
|
i915screen->screen.get_name = i915_get_name;
|
||||||
|
i915screen->screen.get_vendor = i915_get_vendor;
|
||||||
|
|
||||||
|
i915_init_screen_string_functions(&i915screen->screen);
|
||||||
|
i915_init_screen_texture_functions(&i915screen->screen);
|
||||||
|
|
||||||
|
return &i915screen->screen;
|
||||||
|
}
|
60
src/gallium/drivers/i915simple/i915_screen.h
Normal file
60
src/gallium/drivers/i915simple/i915_screen.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sub license, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the
|
||||||
|
* next paragraph) shall be included in all copies or substantial portions
|
||||||
|
* of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||||
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef I915_SCREEN_H
|
||||||
|
#define I915_SCREEN_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "pipe/p_screen.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclass of pipe_screen
|
||||||
|
*/
|
||||||
|
struct i915_screen
|
||||||
|
{
|
||||||
|
struct pipe_screen screen;
|
||||||
|
|
||||||
|
boolean is_i945;
|
||||||
|
uint pci_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** cast wrapper */
|
||||||
|
static INLINE struct i915_screen *
|
||||||
|
i915_screen(struct pipe_screen *pscreen)
|
||||||
|
{
|
||||||
|
return (struct i915_screen *) pscreen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern struct pipe_screen *
|
||||||
|
i915_create_screen(struct pipe_winsys *winsys, uint pci_id);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* I915_SCREEN_H */
|
@@ -26,21 +26,31 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "i915_context.h"
|
#include "i915_context.h"
|
||||||
|
#include "i915_screen.h"
|
||||||
#include "i915_reg.h"
|
#include "i915_reg.h"
|
||||||
|
|
||||||
|
|
||||||
|
/** XXX temporary screen/pipe duplication here */
|
||||||
|
|
||||||
|
|
||||||
|
static const char *i915_get_vendor_screen( struct pipe_screen *screen )
|
||||||
|
{
|
||||||
|
return "Tungsten Graphics, Inc.";
|
||||||
|
}
|
||||||
|
|
||||||
static const char *i915_get_vendor( struct pipe_context *pipe )
|
static const char *i915_get_vendor( struct pipe_context *pipe )
|
||||||
{
|
{
|
||||||
return "Tungsten Graphics, Inc.";
|
return "Tungsten Graphics, Inc.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char *i915_get_name( struct pipe_context *pipe )
|
static const char *i915_get_name_screen( struct pipe_screen *screen )
|
||||||
{
|
{
|
||||||
|
struct i915_screen *i915screen = i915_screen(screen);
|
||||||
static char buffer[128];
|
static char buffer[128];
|
||||||
const char *chipset;
|
const char *chipset;
|
||||||
|
|
||||||
switch (i915_context(pipe)->pci_id) {
|
switch (i915screen->pci_id) {
|
||||||
case PCI_CHIP_I915_G:
|
case PCI_CHIP_I915_G:
|
||||||
chipset = "915G";
|
chipset = "915G";
|
||||||
break;
|
break;
|
||||||
@@ -75,9 +85,22 @@ static const char *i915_get_name( struct pipe_context *pipe )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static const char *i915_get_name( struct pipe_context *pipe )
|
||||||
|
{
|
||||||
|
return pipe->screen->get_name(pipe->screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
i915_init_string_functions(struct i915_context *i915)
|
i915_init_string_functions(struct i915_context *i915)
|
||||||
{
|
{
|
||||||
i915->pipe.get_name = i915_get_name;
|
i915->pipe.get_name = i915_get_name;
|
||||||
i915->pipe.get_vendor = i915_get_vendor;
|
i915->pipe.get_vendor = i915_get_vendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
i915_init_screen_string_functions(struct pipe_screen *screen)
|
||||||
|
{
|
||||||
|
screen->get_name = i915_get_name_screen;
|
||||||
|
screen->get_vendor = i915_get_vendor_screen;
|
||||||
|
}
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
#include "i915_context.h"
|
#include "i915_context.h"
|
||||||
#include "i915_texture.h"
|
#include "i915_texture.h"
|
||||||
#include "i915_debug.h"
|
#include "i915_debug.h"
|
||||||
|
#include "i915_screen.h"
|
||||||
|
|
||||||
|
|
||||||
static unsigned minify( unsigned d )
|
static unsigned minify( unsigned d )
|
||||||
@@ -187,7 +188,7 @@ static const int step_offsets[6][2] = {
|
|||||||
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
i915_miptree_layout(struct i915_texture * tex)
|
||||||
{
|
{
|
||||||
struct pipe_texture *pt = &tex->base;
|
struct pipe_texture *pt = &tex->base;
|
||||||
unsigned level;
|
unsigned level;
|
||||||
@@ -311,7 +312,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||||||
|
|
||||||
|
|
||||||
static boolean
|
static boolean
|
||||||
i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
i945_miptree_layout(struct i915_texture * tex)
|
||||||
{
|
{
|
||||||
struct pipe_texture *pt = &tex->base;
|
struct pipe_texture *pt = &tex->base;
|
||||||
unsigned level;
|
unsigned level;
|
||||||
@@ -479,21 +480,23 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
|
|||||||
|
|
||||||
|
|
||||||
static struct pipe_texture *
|
static struct pipe_texture *
|
||||||
i915_texture_create(struct pipe_context *pipe,
|
i915_texture_create_screen(struct pipe_screen *screen,
|
||||||
const struct pipe_texture *templat)
|
const struct pipe_texture *templat)
|
||||||
{
|
{
|
||||||
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
|
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
|
||||||
|
|
||||||
if (tex) {
|
if (tex) {
|
||||||
struct i915_context *i915 = i915_context(pipe);
|
struct i915_screen *i915screen = i915_screen(screen);
|
||||||
|
struct pipe_winsys *ws = screen->winsys;
|
||||||
|
|
||||||
tex->base = *templat;
|
tex->base = *templat;
|
||||||
tex->base.refcount = 1;
|
tex->base.refcount = 1;
|
||||||
tex->base.pipe = pipe;
|
tex->base.pipe = NULL;
|
||||||
|
tex->base.screen = screen;
|
||||||
|
|
||||||
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
|
if (i915screen->is_i945 ? i945_miptree_layout(tex) :
|
||||||
i915_miptree_layout(pipe, tex))
|
i915_miptree_layout(tex))
|
||||||
tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
|
tex->buffer = ws->buffer_create(ws, 64,
|
||||||
PIPE_BUFFER_USAGE_PIXEL,
|
PIPE_BUFFER_USAGE_PIXEL,
|
||||||
tex->pitch * tex->base.cpp *
|
tex->pitch * tex->base.cpp *
|
||||||
tex->total_height);
|
tex->total_height);
|
||||||
@@ -508,8 +511,17 @@ i915_texture_create(struct pipe_context *pipe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct pipe_texture *
|
||||||
|
i915_texture_create(struct pipe_context *pipe,
|
||||||
|
const struct pipe_texture *templat)
|
||||||
|
{
|
||||||
|
return pipe->screen->texture_create(pipe->screen, templat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
i915_texture_release_screen(struct pipe_screen *screen,
|
||||||
|
struct pipe_texture **pt)
|
||||||
{
|
{
|
||||||
if (!*pt)
|
if (!*pt)
|
||||||
return;
|
return;
|
||||||
@@ -526,7 +538,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
|||||||
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
|
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
|
pipe_buffer_reference(screen->winsys, &tex->buffer, NULL);
|
||||||
|
|
||||||
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
|
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
|
||||||
if (tex->image_offset[i])
|
if (tex->image_offset[i])
|
||||||
@@ -538,6 +550,13 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
||||||
|
{
|
||||||
|
i915_texture_release_screen(pipe->screen, pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
|
i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
|
||||||
{
|
{
|
||||||
@@ -549,11 +568,12 @@ i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
|
|||||||
* XXX note: same as code in sp_surface.c
|
* XXX note: same as code in sp_surface.c
|
||||||
*/
|
*/
|
||||||
static struct pipe_surface *
|
static struct pipe_surface *
|
||||||
i915_get_tex_surface(struct pipe_context *pipe,
|
i915_get_tex_surface_screen(struct pipe_screen *screen,
|
||||||
struct pipe_texture *pt,
|
struct pipe_texture *pt,
|
||||||
unsigned face, unsigned level, unsigned zslice)
|
unsigned face, unsigned level, unsigned zslice)
|
||||||
{
|
{
|
||||||
struct i915_texture *tex = (struct i915_texture *)pt;
|
struct i915_texture *tex = (struct i915_texture *)pt;
|
||||||
|
struct pipe_winsys *ws = screen->winsys;
|
||||||
struct pipe_surface *ps;
|
struct pipe_surface *ps;
|
||||||
unsigned offset; /* in bytes */
|
unsigned offset; /* in bytes */
|
||||||
|
|
||||||
@@ -570,11 +590,11 @@ i915_get_tex_surface(struct pipe_context *pipe,
|
|||||||
assert(zslice == 0);
|
assert(zslice == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ps = pipe->winsys->surface_alloc(pipe->winsys);
|
ps = ws->surface_alloc(ws);
|
||||||
if (ps) {
|
if (ps) {
|
||||||
assert(ps->refcount);
|
assert(ps->refcount);
|
||||||
assert(ps->winsys);
|
assert(ps->winsys);
|
||||||
pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
|
pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
|
||||||
ps->format = pt->format;
|
ps->format = pt->format;
|
||||||
ps->cpp = pt->cpp;
|
ps->cpp = pt->cpp;
|
||||||
ps->width = pt->width[level];
|
ps->width = pt->width[level];
|
||||||
@@ -586,6 +606,14 @@ i915_get_tex_surface(struct pipe_context *pipe,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct pipe_surface *
|
||||||
|
i915_get_tex_surface(struct pipe_context *pipe,
|
||||||
|
struct pipe_texture *pt,
|
||||||
|
unsigned face, unsigned level, unsigned zslice)
|
||||||
|
{
|
||||||
|
return i915_get_tex_surface_screen(pipe->screen, pt, face, level, zslice);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
i915_init_texture_functions(struct i915_context *i915)
|
i915_init_texture_functions(struct i915_context *i915)
|
||||||
@@ -595,3 +623,13 @@ i915_init_texture_functions(struct i915_context *i915)
|
|||||||
i915->pipe.texture_update = i915_texture_update;
|
i915->pipe.texture_update = i915_texture_update;
|
||||||
i915->pipe.get_tex_surface = i915_get_tex_surface;
|
i915->pipe.get_tex_surface = i915_get_tex_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
i915_init_screen_texture_functions(struct pipe_screen *screen)
|
||||||
|
{
|
||||||
|
screen->texture_create = i915_texture_create_screen;
|
||||||
|
screen->texture_release = i915_texture_release_screen;
|
||||||
|
screen->get_tex_surface = i915_get_tex_surface_screen;
|
||||||
|
}
|
||||||
|
@@ -28,11 +28,16 @@
|
|||||||
#ifndef I915_TEXTURE_H
|
#ifndef I915_TEXTURE_H
|
||||||
#define I915_TEXTURE_H
|
#define I915_TEXTURE_H
|
||||||
|
|
||||||
struct pipe_context;
|
struct i915_context;
|
||||||
|
struct pipe_screen;
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
i915_init_texture_functions(struct i915_context *i915);
|
i915_init_texture_functions(struct i915_context *i915);
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
i915_init_screen_texture_functions(struct pipe_screen *screen);
|
||||||
|
|
||||||
|
|
||||||
#endif /* I915_TEXTURE_H */
|
#endif /* I915_TEXTURE_H */
|
||||||
|
@@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
struct pipe_buffer;
|
struct pipe_buffer;
|
||||||
struct pipe_winsys;
|
struct pipe_winsys;
|
||||||
|
struct pipe_screen;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,9 +108,8 @@ struct i915_winsys {
|
|||||||
#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
|
#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
|
||||||
|
|
||||||
|
|
||||||
struct pipe_context *i915_create( struct pipe_winsys *,
|
struct pipe_context *i915_create_context( struct pipe_screen *,
|
||||||
struct i915_winsys *,
|
struct pipe_winsys *,
|
||||||
unsigned pci_id );
|
struct i915_winsys * );
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -36,6 +36,8 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
struct pipe_screen;
|
||||||
|
|
||||||
struct pipe_state_cache;
|
struct pipe_state_cache;
|
||||||
|
|
||||||
/* Opaque driver handles:
|
/* Opaque driver handles:
|
||||||
@@ -51,6 +53,7 @@ struct pipe_query;
|
|||||||
*/
|
*/
|
||||||
struct pipe_context {
|
struct pipe_context {
|
||||||
struct pipe_winsys *winsys;
|
struct pipe_winsys *winsys;
|
||||||
|
struct pipe_screen *screen;
|
||||||
|
|
||||||
void *priv; /** context private data (for DRI for example) */
|
void *priv; /** context private data (for DRI for example) */
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "p_context.h"
|
#include "p_context.h"
|
||||||
#include "p_defines.h"
|
#include "p_defines.h"
|
||||||
|
#include "p_screen.h"
|
||||||
#include "p_winsys.h"
|
#include "p_winsys.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -107,7 +108,15 @@ pipe_texture_reference(struct pipe_texture **ptr,
|
|||||||
|
|
||||||
if (*ptr) {
|
if (*ptr) {
|
||||||
struct pipe_context *pipe = (*ptr)->pipe;
|
struct pipe_context *pipe = (*ptr)->pipe;
|
||||||
|
/* XXX temporary mess here */
|
||||||
|
if (pipe) {
|
||||||
pipe->texture_release(pipe, ptr);
|
pipe->texture_release(pipe, ptr);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
struct pipe_screen *screen = (*ptr)->screen;
|
||||||
|
screen->texture_release(screen, ptr);
|
||||||
|
}
|
||||||
|
|
||||||
assert(!*ptr);
|
assert(!*ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
98
src/gallium/include/pipe/p_screen.h
Normal file
98
src/gallium/include/pipe/p_screen.h
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
/**************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sub license, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice (including the
|
||||||
|
* next paragraph) shall be included in all copies or substantial portions
|
||||||
|
* of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||||
|
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Screen, Adapter or GPU
|
||||||
|
*
|
||||||
|
* These are driver functions/facilities that are context independent.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef P_SCREEN_H
|
||||||
|
#define P_SCREEN_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "pipe/p_compiler.h"
|
||||||
|
#include "pipe/p_state.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gallium screen/adapter context. Basically everything
|
||||||
|
* hardware-specific that doesn't actually require a rendering
|
||||||
|
* context.
|
||||||
|
*/
|
||||||
|
struct pipe_screen {
|
||||||
|
struct pipe_winsys *winsys;
|
||||||
|
|
||||||
|
void (*destroy)( struct pipe_screen * );
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Capability queries
|
||||||
|
*/
|
||||||
|
const char *(*get_name)( struct pipe_screen * );
|
||||||
|
|
||||||
|
const char *(*get_vendor)( struct pipe_screen * );
|
||||||
|
|
||||||
|
int (*get_param)( struct pipe_screen *, int param );
|
||||||
|
|
||||||
|
float (*get_paramf)( struct pipe_screen *, int param );
|
||||||
|
|
||||||
|
boolean (*is_format_supported)( struct pipe_screen *,
|
||||||
|
enum pipe_format format,
|
||||||
|
uint type );
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Texture functions
|
||||||
|
*/
|
||||||
|
struct pipe_texture * (*texture_create)(struct pipe_screen *,
|
||||||
|
const struct pipe_texture *templat);
|
||||||
|
|
||||||
|
void (*texture_release)(struct pipe_screen *,
|
||||||
|
struct pipe_texture **pt);
|
||||||
|
|
||||||
|
/** Get a surface which is a "view" into a texture */
|
||||||
|
struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
|
||||||
|
struct pipe_texture *texture,
|
||||||
|
unsigned face, unsigned level,
|
||||||
|
unsigned zslice);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* P_SCREEN_H */
|
@@ -63,6 +63,7 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
/* fwd decls */
|
/* fwd decls */
|
||||||
|
struct pipe_screen;
|
||||||
struct pipe_surface;
|
struct pipe_surface;
|
||||||
struct pipe_winsys;
|
struct pipe_winsys;
|
||||||
|
|
||||||
@@ -301,6 +302,7 @@ struct pipe_texture
|
|||||||
* XXX this'll change to a pipe_winsys (or pipe_screen)...
|
* XXX this'll change to a pipe_winsys (or pipe_screen)...
|
||||||
*/
|
*/
|
||||||
struct pipe_context *pipe;
|
struct pipe_context *pipe;
|
||||||
|
struct pipe_screen *screen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include "pipe/p_util.h"
|
#include "pipe/p_util.h"
|
||||||
#include "i915simple/i915_winsys.h"
|
#include "i915simple/i915_winsys.h"
|
||||||
|
#include "i915simple/i915_screen.h"
|
||||||
|
|
||||||
|
|
||||||
struct intel_i915_winsys {
|
struct intel_i915_winsys {
|
||||||
@@ -135,6 +136,7 @@ intel_create_i915simple( struct intel_context *intel,
|
|||||||
struct pipe_winsys *winsys )
|
struct pipe_winsys *winsys )
|
||||||
{
|
{
|
||||||
struct intel_i915_winsys *iws = CALLOC_STRUCT( intel_i915_winsys );
|
struct intel_i915_winsys *iws = CALLOC_STRUCT( intel_i915_winsys );
|
||||||
|
struct pipe_screen *screen;
|
||||||
|
|
||||||
/* Fill in this struct with callbacks that i915simple will need to
|
/* Fill in this struct with callbacks that i915simple will need to
|
||||||
* communicate with the window system, buffer manager, etc.
|
* communicate with the window system, buffer manager, etc.
|
||||||
@@ -146,9 +148,11 @@ intel_create_i915simple( struct intel_context *intel,
|
|||||||
iws->winsys.batch_finish = intel_i915_batch_finish;
|
iws->winsys.batch_finish = intel_i915_batch_finish;
|
||||||
iws->intel = intel;
|
iws->intel = intel;
|
||||||
|
|
||||||
|
screen = i915_create_screen(winsys, intel->intelScreen->deviceID);
|
||||||
|
|
||||||
/* Create the i915simple context:
|
/* Create the i915simple context:
|
||||||
*/
|
*/
|
||||||
return i915_create( winsys,
|
return i915_create_context( screen,
|
||||||
&iws->winsys,
|
winsys,
|
||||||
intel->intelScreen->deviceID );
|
&iws->winsys );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user