if (This->may_swvp)
This->caps.MaxVertexShaderConst = NINE_MAX_CONST_F_SWVP;
- This->pipe = This->screen->context_create(This->screen, NULL, 0);
- if (!This->pipe) { return E_OUTOFMEMORY; } /* guess */
+ This->context.pipe = This->screen->context_create(This->screen, NULL, 0);
+ if (!This->context.pipe) { return E_OUTOFMEMORY; } /* guess */
This->pipe_sw = This->screen_sw->context_create(This->screen_sw, NULL, 0);
if (!This->pipe_sw) { return E_OUTOFMEMORY; }
- This->cso = cso_create_context(This->pipe);
- if (!This->cso) { return E_OUTOFMEMORY; } /* also a guess */
+ This->context.cso = cso_create_context(This->context.pipe);
+ if (!This->context.cso) { return E_OUTOFMEMORY; } /* also a guess */
This->cso_sw = cso_create_context(This->pipe_sw);
if (!This->cso_sw) { return E_OUTOFMEMORY; }
/* Create first, it messes up our state. */
- This->hud = hud_create(This->pipe, This->cso); /* NULL result is fine */
+ This->hud = hud_create(This->context.pipe, This->context.cso); /* NULL result is fine */
/* Available memory counter. Updated only for allocations with this device
* instance. This is the Win 7 behavior.
return D3DERR_OUTOFVIDEOMEMORY;
u_box_1d(0, 16, &box);
- data = This->pipe->transfer_map(This->pipe, This->dummy_vbo, 0,
+ data = This->context.pipe->transfer_map(This->context.pipe, This->dummy_vbo, 0,
PIPE_TRANSFER_WRITE |
PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE,
&box, &transfer);
assert(data);
assert(transfer);
memset(data, 0, 16);
- This->pipe->transfer_unmap(This->pipe, transfer);
+ This->context.pipe->transfer_unmap(This->context.pipe, transfer);
}
This->cursor.software = FALSE;
templ.swizzle_a = PIPE_SWIZZLE_1;
templ.target = This->dummy_texture->target;
- This->dummy_sampler_view = This->pipe->create_sampler_view(This->pipe, This->dummy_texture, &templ);
+ This->dummy_sampler_view = This->context.pipe->create_sampler_view(This->context.pipe, This->dummy_texture, &templ);
if (!This->dummy_sampler_view)
return D3DERR_DRIVERINTERNALERROR;
This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
if (!This->driver_caps.user_vbufs)
- This->vertex_uploader = u_upload_create(This->pipe, 65536,
+ This->vertex_uploader = u_upload_create(This->context.pipe, 65536,
PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
This->vertex_sw_uploader = u_upload_create(This->pipe_sw, 65536,
PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_STREAM);
if (!This->driver_caps.user_ibufs)
- This->index_uploader = u_upload_create(This->pipe, 128 * 1024,
+ This->index_uploader = u_upload_create(This->context.pipe, 128 * 1024,
PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_STREAM);
if (!This->driver_caps.user_cbufs) {
This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
- This->constbuf_uploader = u_upload_create(This->pipe, This->vs_const_size,
+ This->constbuf_uploader = u_upload_create(This->context.pipe, This->vs_const_size,
PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_STREAM);
}
{
struct pipe_poly_stipple stipple;
memset(&stipple, ~0, sizeof(stipple));
- This->pipe->set_polygon_stipple(This->pipe, &stipple);
+ This->context.pipe->set_polygon_stipple(This->context.pipe, &stipple);
}
This->update = &This->state;
DBG("This=%p\n", This);
- if (This->pipe && This->cso)
+ if (This->context.pipe && This->context.cso)
nine_pipe_context_clear(This);
nine_ff_fini(This);
nine_state_destroy_sw(This);
}
/* Destroy cso first */
- if (This->cso) { cso_destroy_context(This->cso); }
+ if (This->context.cso) { cso_destroy_context(This->context.cso); }
if (This->cso_sw) { cso_destroy_context(This->cso_sw); }
- if (This->pipe && This->pipe->destroy) { This->pipe->destroy(This->pipe); }
+ if (This->context.pipe && This->context.pipe->destroy) { This->context.pipe->destroy(This->context.pipe); }
if (This->pipe_sw && This->pipe_sw->destroy) { This->pipe_sw->destroy(This->pipe_sw); }
if (This->present) { ID3DPresentGroup_Release(This->present); }
struct pipe_context *
NineDevice9_GetPipe( struct NineDevice9 *This )
{
- return This->pipe;
+ return This->context.pipe;
}
const D3DCAPS9 *
static void
update_framebuffer(struct NineDevice9 *device, bool is_clear)
{
- struct pipe_context *pipe = device->pipe;
struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
struct pipe_framebuffer_state *fb = &context->pipe_data.fb;
unsigned i;
struct NineSurface9 *rt0 = context->rt[0];
static void
update_viewport(struct NineDevice9 *device)
{
- const D3DVIEWPORT9 *vport = &device->context.viewport;
+ struct nine_context *context = &device->context;
+ const D3DVIEWPORT9 *vport = &context->viewport;
struct pipe_viewport_state pvport;
/* D3D coordinates are:
pvport.translate[1] -= 1.0f / 128.0f;
}
- cso_set_viewport(device->cso, &pvport);
+ cso_set_viewport(context->cso, &pvport);
}
/* Loop through VS inputs and pick the vertex elements with the declared
context->dummy_vbo_bound_at = dummy_vbo_stream;
}
- cso_set_vertex_elements(device->cso, vs->num_inputs, ve);
+ cso_set_vertex_elements(context->cso, vs->num_inputs, ve);
}
static void
update_vertex_buffers(struct NineDevice9 *device)
{
- struct pipe_context *pipe = device->pipe;
struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
struct pipe_vertex_buffer dummy_vtxbuf;
uint32_t mask = context->changed.vtxbuf;
unsigned i;
if (update_sampler_derived(context, s) || (context->changed.sampler[s] & 0x05fe)) {
context->changed.sampler[s] = 0;
commit_samplers = TRUE;
- nine_convert_sampler_state(device->cso, s, context->samp[s]);
+ nine_convert_sampler_state(context->cso, s, context->samp[s]);
}
} else {
/* Bind dummy sampler. We do not bind dummy sampler when
view[i] = device->dummy_sampler_view;
num_textures = i + 1;
- cso_single_sampler(device->cso, PIPE_SHADER_FRAGMENT,
+ cso_single_sampler(context->cso, PIPE_SHADER_FRAGMENT,
s - NINE_SAMPLER_PS(0), &device->dummy_sampler_state);
commit_samplers = TRUE;
context->bound_samplers_mask_ps |= (1 << s);
}
- cso_set_sampler_views(device->cso, PIPE_SHADER_FRAGMENT, num_textures, view);
+ cso_set_sampler_views(context->cso, PIPE_SHADER_FRAGMENT, num_textures, view);
if (commit_samplers)
- cso_single_sampler_done(device->cso, PIPE_SHADER_FRAGMENT);
+ cso_single_sampler_done(context->cso, PIPE_SHADER_FRAGMENT);
commit_samplers = FALSE;
sampler_mask = context->programmable_vs ? context->vs->sampler_mask : 0;
if (update_sampler_derived(context, s) || (context->changed.sampler[s] & 0x05fe)) {
context->changed.sampler[s] = 0;
commit_samplers = TRUE;
- nine_convert_sampler_state(device->cso, s, context->samp[s]);
+ nine_convert_sampler_state(context->cso, s, context->samp[s]);
}
} else {
/* Bind dummy sampler. We do not bind dummy sampler when
view[i] = device->dummy_sampler_view;
num_textures = i + 1;
- cso_single_sampler(device->cso, PIPE_SHADER_VERTEX,
+ cso_single_sampler(context->cso, PIPE_SHADER_VERTEX,
s - NINE_SAMPLER_VS(0), &device->dummy_sampler_state);
commit_samplers = TRUE;
context->bound_samplers_mask_vs |= (1 << s);
}
- cso_set_sampler_views(device->cso, PIPE_SHADER_VERTEX, num_textures, view);
+ cso_set_sampler_views(context->cso, PIPE_SHADER_VERTEX, num_textures, view);
if (commit_samplers)
- cso_single_sampler_done(device->cso, PIPE_SHADER_VERTEX);
+ cso_single_sampler_done(context->cso, PIPE_SHADER_VERTEX);
}
/* State commit only */
static inline void
commit_blend(struct NineDevice9 *device)
{
- cso_set_blend(device->cso, &device->context.pipe_data.blend);
+ struct nine_context *context = &device->context;
+
+ cso_set_blend(context->cso, &context->pipe_data.blend);
}
static inline void
commit_dsa(struct NineDevice9 *device)
{
- cso_set_depth_stencil_alpha(device->cso, &device->context.pipe_data.dsa);
+ struct nine_context *context = &device->context;
+
+ cso_set_depth_stencil_alpha(context->cso, &context->pipe_data.dsa);
}
static inline void
commit_scissor(struct NineDevice9 *device)
{
- struct pipe_context *pipe = device->pipe;
+ struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
- pipe->set_scissor_states(pipe, 0, 1, &device->context.scissor);
+ pipe->set_scissor_states(pipe, 0, 1, &context->scissor);
}
static inline void
commit_rasterizer(struct NineDevice9 *device)
{
- cso_set_rasterizer(device->cso, &device->context.pipe_data.rast);
+ struct nine_context *context = &device->context;
+
+ cso_set_rasterizer(context->cso, &context->pipe_data.rast);
}
static inline void
commit_index_buffer(struct NineDevice9 *device)
{
- struct pipe_context *pipe = device->pipe;
- if (device->context.idxbuf.buffer)
- pipe->set_index_buffer(pipe, &device->context.idxbuf);
+ struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
+ if (context->idxbuf.buffer)
+ pipe->set_index_buffer(pipe, &context->idxbuf);
else
pipe->set_index_buffer(pipe, NULL);
}
static inline void
commit_vs_constants(struct NineDevice9 *device)
{
- struct pipe_context *pipe = device->pipe;
+ struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
- if (unlikely(!device->context.programmable_vs))
- pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe_data.cb_vs_ff);
+ if (unlikely(!context->programmable_vs))
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb_vs_ff);
else {
if (device->swvp) {
- pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe_data.cb0_swvp);
- pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 1, &device->context.pipe_data.cb1_swvp);
- pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 2, &device->context.pipe_data.cb2_swvp);
- pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 3, &device->context.pipe_data.cb3_swvp);
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb0_swvp);
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 1, &context->pipe_data.cb1_swvp);
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 2, &context->pipe_data.cb2_swvp);
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 3, &context->pipe_data.cb3_swvp);
} else {
- pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &device->context.pipe_data.cb_vs);
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_VERTEX, 0, &context->pipe_data.cb_vs);
}
}
}
static inline void
commit_ps_constants(struct NineDevice9 *device)
{
- struct pipe_context *pipe = device->pipe;
+ struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
- if (unlikely(!device->context.ps))
- pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &device->context.pipe_data.cb_ps_ff);
+ if (unlikely(!context->ps))
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->pipe_data.cb_ps_ff);
else
- pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &device->context.pipe_data.cb_ps);
+ pipe->set_constant_buffer(pipe, PIPE_SHADER_FRAGMENT, 0, &context->pipe_data.cb_ps);
}
static inline void
{
struct nine_context *context = &device->context;
- device->pipe->bind_vs_state(device->pipe, context->cso_shader.vs);
+ context->pipe->bind_vs_state(context->pipe, context->cso_shader.vs);
}
{
struct nine_context *context = &device->context;
- device->pipe->bind_fs_state(device->pipe, context->cso_shader.ps);
+ context->pipe->bind_fs_state(context->pipe, context->cso_shader.ps);
}
/* State Update */
static void
nine_update_state(struct NineDevice9 *device)
{
- struct pipe_context *pipe = device->pipe;
struct nine_context *context = &device->context;
+ struct pipe_context *pipe = context->pipe;
uint32_t group;
DBG("changed state groups: %x\n", context->changed.group);
blit.filter = PIPE_TEX_FILTER_NEAREST;
blit.scissor_enable = FALSE;
- device->pipe->blit(device->pipe, &blit);
+ context->pipe->blit(context->pipe, &blit);
}
#define ALPHA_TO_COVERAGE_ENABLE MAKEFOURCC('A', '2', 'M', '1')
struct nine_context *context = &device->context;
const int sRGB = context->rs[D3DRS_SRGBWRITEENABLE] ? 1 : 0;
struct pipe_surface *cbuf, *zsbuf;
- struct pipe_context *pipe = device->pipe;
+ struct pipe_context *pipe = context->pipe;
struct NineSurface9 *zsbuf_surf = context->ds;
struct NineSurface9 *rt;
unsigned bufs = 0;
UINT StartVertex,
UINT PrimitiveCount)
{
+ struct nine_context *context = &device->context;
struct pipe_draw_info info;
nine_update_state(device);
info.min_index = info.start;
info.max_index = info.count - 1;
- device->pipe->draw_vbo(device->pipe, &info);
+ context->pipe->draw_vbo(context->pipe, &info);
}
void
UINT StartIndex,
UINT PrimitiveCount)
{
+ struct nine_context *context = &device->context;
struct pipe_draw_info info;
nine_update_state(device);
info.min_index = MinVertexIndex;
info.max_index = MinVertexIndex + NumVertices - 1;
- device->pipe->draw_vbo(device->pipe, &info);
+ context->pipe->draw_vbo(context->pipe, &info);
}
void
UINT PrimitiveCount,
struct pipe_vertex_buffer *vtxbuf)
{
+ struct nine_context *context = &device->context;
struct pipe_draw_info info;
nine_update_state(device);
info.min_index = 0;
info.max_index = info.count - 1;
- device->pipe->set_vertex_buffers(device->pipe, 0, 1, vtxbuf);
+ context->pipe->set_vertex_buffers(context->pipe, 0, 1, vtxbuf);
- device->pipe->draw_vbo(device->pipe, &info);
+ context->pipe->draw_vbo(context->pipe, &info);
}
void
struct pipe_vertex_buffer *vbuf,
struct pipe_index_buffer *ibuf)
{
+ struct nine_context *context = &device->context;
struct pipe_draw_info info;
nine_update_state(device);
info.index_bias = 0;
info.min_index = MinVertexIndex;
info.max_index = MinVertexIndex + NumVertices - 1;
- device->pipe->set_vertex_buffers(device->pipe, 0, 1, vbuf);
- device->pipe->set_index_buffer(device->pipe, ibuf);
+ context->pipe->set_vertex_buffers(context->pipe, 0, 1, vbuf);
+ context->pipe->set_index_buffer(context->pipe, ibuf);
- device->pipe->draw_vbo(device->pipe, &info);
+ context->pipe->draw_vbo(context->pipe, &info);
}
struct pipe_query *
nine_context_create_query(struct NineDevice9 *device, unsigned query_type)
{
- return device->pipe->create_query(device->pipe, query_type, 0);
+ struct nine_context *context = &device->context;
+
+ return context->pipe->create_query(context->pipe, query_type, 0);
}
void
nine_context_destroy_query(struct NineDevice9 *device, struct pipe_query *query)
{
- device->pipe->destroy_query(device->pipe, query);
+ struct nine_context *context = &device->context;
+
+ context->pipe->destroy_query(context->pipe, query);
}
void
nine_context_begin_query(struct NineDevice9 *device, struct pipe_query *query)
{
- (void) device->pipe->begin_query(device->pipe, query);
+ struct nine_context *context = &device->context;
+
+ (void) context->pipe->begin_query(context->pipe, query);
}
void
nine_context_end_query(struct NineDevice9 *device, struct pipe_query *query)
{
- (void) device->pipe->end_query(device->pipe, query);
+ struct nine_context *context = &device->context;
+
+ (void) context->pipe->end_query(context->pipe, query);
}
boolean
boolean flush, boolean wait,
union pipe_query_result *result)
{
+ struct nine_context *context = &device->context;
+
(void) flush;
- return device->pipe->get_query_result(device->pipe, query, wait, result);
+ return context->pipe->get_query_result(context->pipe, query, wait, result);
}
/* State defaults */
static void
update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_vertices)
{
- struct pipe_context *pipe = device->pipe;
+ struct pipe_context *pipe = NineDevice9_GetPipe(device);
struct pipe_context *pipe_sw = device->pipe_sw;
struct nine_state *state = &device->state;
struct nine_state_sw_internal *sw_internal = &device->state_sw_internal;
nine_state_after_draw_sw(struct NineDevice9 *device)
{
struct nine_state_sw_internal *sw_internal = &device->state_sw_internal;
- struct pipe_context *pipe = device->pipe;
+ struct pipe_context *pipe = NineDevice9_GetPipe(device);
struct pipe_context *pipe_sw = device->pipe_sw;
int i;