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