python: Update python state tracker and samples for recent interface changes.
This commit is contained in:
@@ -52,11 +52,16 @@ struct st_context {
|
||||
cso_set_blend($self->cso, state);
|
||||
}
|
||||
|
||||
void set_sampler( unsigned index, const struct pipe_sampler_state *state ) {
|
||||
void set_fragment_sampler( unsigned index, const struct pipe_sampler_state *state ) {
|
||||
cso_single_sampler($self->cso, index, state);
|
||||
cso_single_sampler_done($self->cso);
|
||||
}
|
||||
|
||||
void set_vertex_sampler( unsigned index, const struct pipe_sampler_state *state ) {
|
||||
cso_single_vertex_sampler($self->cso, index, state);
|
||||
cso_single_vertex_sampler_done($self->cso);
|
||||
}
|
||||
|
||||
void set_rasterizer( const struct pipe_rasterizer_state *state ) {
|
||||
cso_set_rasterizer($self->cso, state);
|
||||
}
|
||||
@@ -161,14 +166,24 @@ struct st_context {
|
||||
cso_set_viewport($self->cso, state);
|
||||
}
|
||||
|
||||
void set_sampler_texture(unsigned index,
|
||||
void set_fragment_sampler_texture(unsigned index,
|
||||
struct pipe_texture *texture) {
|
||||
if(!texture)
|
||||
texture = $self->default_texture;
|
||||
pipe_texture_reference(&$self->sampler_textures[index], texture);
|
||||
pipe_texture_reference(&$self->fragment_sampler_textures[index], texture);
|
||||
$self->pipe->set_fragment_sampler_textures($self->pipe,
|
||||
PIPE_MAX_SAMPLERS,
|
||||
$self->sampler_textures);
|
||||
$self->fragment_sampler_textures);
|
||||
}
|
||||
|
||||
void set_vertex_sampler_texture(unsigned index,
|
||||
struct pipe_texture *texture) {
|
||||
if(!texture)
|
||||
texture = $self->default_texture;
|
||||
pipe_texture_reference(&$self->vertex_sampler_textures[index], texture);
|
||||
$self->pipe->set_vertex_sampler_textures($self->pipe,
|
||||
PIPE_MAX_VERTEX_SAMPLERS,
|
||||
$self->vertex_sampler_textures);
|
||||
}
|
||||
|
||||
void set_vertex_buffer(unsigned index,
|
||||
|
@@ -278,9 +278,9 @@ class Screen(Object):
|
||||
def texture_create(self, templat):
|
||||
return self.real.texture_create(
|
||||
format = templat.format,
|
||||
width = templat.width0,
|
||||
height = templat.height0,
|
||||
depth = templat.depth0,
|
||||
width = templat.width,
|
||||
height = templat.height,
|
||||
depth = templat.depth,
|
||||
last_level = templat.last_level,
|
||||
target = templat.target,
|
||||
tex_usage = templat.tex_usage,
|
||||
@@ -387,9 +387,13 @@ class Context(Object):
|
||||
def delete_sampler_state(self, state):
|
||||
pass
|
||||
|
||||
def bind_vertex_sampler_states(self, num_states, states):
|
||||
for i in range(num_states):
|
||||
self.real.set_vertex_sampler(i, states[i])
|
||||
|
||||
def bind_fragment_sampler_states(self, num_states, states):
|
||||
for i in range(num_states):
|
||||
self.real.set_sampler(i, states[i])
|
||||
self.real.set_fragment_sampler(i, states[i])
|
||||
|
||||
def create_rasterizer_state(self, state):
|
||||
return state
|
||||
@@ -487,7 +491,11 @@ class Context(Object):
|
||||
|
||||
def set_fragment_sampler_textures(self, num_textures, textures):
|
||||
for i in range(num_textures):
|
||||
self.real.set_sampler_texture(i, textures[i])
|
||||
self.real.set_fragment_sampler_texture(i, textures[i])
|
||||
|
||||
def set_vertex_sampler_textures(self, num_textures, textures):
|
||||
for i in range(num_textures):
|
||||
self.real.set_vertex_sampler_texture(i, textures[i])
|
||||
|
||||
def set_vertex_buffers(self, num_buffers, buffers):
|
||||
self.vbufs = buffers[0:num_buffers]
|
||||
|
@@ -118,7 +118,7 @@ def test(dev):
|
||||
sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
|
||||
sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
|
||||
sampler.normalized_coords = 1
|
||||
ctx.set_sampler(0, sampler)
|
||||
ctx.set_fragment_sampler(0, sampler)
|
||||
|
||||
# scissor
|
||||
scissor = Scissor()
|
||||
|
@@ -135,7 +135,9 @@ st_context_destroy(struct st_context *st_ctx)
|
||||
st_ctx->pipe->destroy(st_ctx->pipe);
|
||||
|
||||
for(i = 0; i < PIPE_MAX_SAMPLERS; ++i)
|
||||
pipe_texture_reference(&st_ctx->sampler_textures[i], NULL);
|
||||
pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], NULL);
|
||||
for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
|
||||
pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], NULL);
|
||||
pipe_texture_reference(&st_ctx->default_texture, NULL);
|
||||
|
||||
FREE(st_ctx);
|
||||
@@ -276,9 +278,12 @@ st_context_create(struct st_device *st_dev)
|
||||
}
|
||||
|
||||
for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
|
||||
pipe_texture_reference(&st_ctx->sampler_textures[i], st_ctx->default_texture);
|
||||
pipe_texture_reference(&st_ctx->fragment_sampler_textures[i], st_ctx->default_texture);
|
||||
for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
|
||||
pipe_texture_reference(&st_ctx->vertex_sampler_textures[i], st_ctx->default_texture);
|
||||
|
||||
cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->sampler_textures);
|
||||
cso_set_sampler_textures(st_ctx->cso, PIPE_MAX_SAMPLERS, st_ctx->fragment_sampler_textures);
|
||||
cso_set_vertex_sampler_textures(st_ctx->cso, PIPE_MAX_VERTEX_SAMPLERS, st_ctx->vertex_sampler_textures);
|
||||
}
|
||||
|
||||
/* vertex shader */
|
||||
|
@@ -60,7 +60,8 @@ struct st_context {
|
||||
void *gs;
|
||||
|
||||
struct pipe_texture *default_texture;
|
||||
struct pipe_texture *sampler_textures[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_texture *fragment_sampler_textures[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_texture *vertex_sampler_textures[PIPE_MAX_VERTEX_SAMPLERS];
|
||||
|
||||
unsigned num_vertex_buffers;
|
||||
struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
|
||||
|
@@ -96,7 +96,7 @@ def test(dev, name):
|
||||
sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
|
||||
sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
|
||||
sampler.normalized_coords = 1
|
||||
ctx.set_sampler(0, sampler)
|
||||
ctx.set_fragment_sampler(0, sampler)
|
||||
|
||||
# scissor
|
||||
scissor = Scissor()
|
||||
|
@@ -96,7 +96,7 @@ def test(dev, name):
|
||||
sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST
|
||||
sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST
|
||||
sampler.normalized_coords = 1
|
||||
ctx.set_sampler(0, sampler)
|
||||
ctx.set_fragment_sampler(0, sampler)
|
||||
|
||||
# scissor
|
||||
scissor = Scissor()
|
||||
|
@@ -144,8 +144,8 @@ class TextureTest(TestCase):
|
||||
sampler.normalized_coords = 1
|
||||
sampler.min_lod = 0
|
||||
sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
|
||||
ctx.set_sampler(0, sampler)
|
||||
ctx.set_sampler_texture(0, src_texture)
|
||||
ctx.set_fragment_sampler(0, sampler)
|
||||
ctx.set_fragment_sampler_texture(0, src_texture)
|
||||
|
||||
# framebuffer
|
||||
cbuf_tex = dev.texture_create(
|
||||
|
@@ -169,7 +169,7 @@ class TextureColorSampleTest(TestCase):
|
||||
sampler.normalized_coords = 1
|
||||
sampler.min_lod = 0
|
||||
sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
|
||||
ctx.set_sampler(0, sampler)
|
||||
ctx.set_fragment_sampler(0, sampler)
|
||||
|
||||
# texture
|
||||
texture = dev.texture_create(
|
||||
@@ -189,7 +189,7 @@ class TextureColorSampleTest(TestCase):
|
||||
zslice = zslice,
|
||||
).sample_rgba(expected_rgba)
|
||||
|
||||
ctx.set_sampler_texture(0, texture)
|
||||
ctx.set_fragment_sampler_texture(0, texture)
|
||||
|
||||
# framebuffer
|
||||
cbuf_tex = dev.texture_create(
|
||||
@@ -359,7 +359,7 @@ class TextureDepthSampleTest(TestCase):
|
||||
sampler.normalized_coords = 1
|
||||
sampler.min_lod = 0
|
||||
sampler.max_lod = PIPE_MAX_TEXTURE_LEVELS - 1
|
||||
ctx.set_sampler(0, sampler)
|
||||
ctx.set_fragment_sampler(0, sampler)
|
||||
|
||||
# texture
|
||||
texture = dev.texture_create(
|
||||
@@ -379,7 +379,7 @@ class TextureDepthSampleTest(TestCase):
|
||||
zslice = zslice,
|
||||
).sample_rgba(expected_rgba)
|
||||
|
||||
ctx.set_sampler_texture(0, texture)
|
||||
ctx.set_fragment_sampler_texture(0, texture)
|
||||
|
||||
# framebuffer
|
||||
cbuf_tex = dev.texture_create(
|
||||
|
Reference in New Issue
Block a user