[Mesa-dev] [PATCH 06/10] nine: assume that user constant buffers are always supported
Marek Olšák
maraeo at gmail.com
Wed Jan 10 19:49:30 UTC 2018
From: Marek Olšák <marek.olsak at amd.com>
---
src/gallium/state_trackers/nine/device9.c | 4 -
src/gallium/state_trackers/nine/device9.h | 3 -
src/gallium/state_trackers/nine/nine_ff.c | 28 +-----
src/gallium/state_trackers/nine/nine_state.c | 125 +--------------------------
4 files changed, 4 insertions(+), 156 deletions(-)
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 34f903a..127f2ae 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -466,26 +466,22 @@ NineDevice9_ctor( struct NineDevice9 *This,
samp.compare_mode = PIPE_TEX_COMPARE_NONE;
samp.compare_func = PIPE_FUNC_LEQUAL;
samp.normalized_coords = 1;
samp.seamless_cube_map = 0;
This->dummy_sampler_state = samp;
}
/* Allocate upload helper for drivers that suck (from st pov ;). */
This->driver_caps.user_vbufs = GET_PCAP(USER_VERTEX_BUFFERS) && !This->csmt_active;
- This->driver_caps.user_cbufs = GET_PCAP(USER_CONSTANT_BUFFERS);
This->driver_caps.user_sw_vbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_VERTEX_BUFFERS);
- This->driver_caps.user_sw_cbufs = This->screen_sw->get_param(This->screen_sw, PIPE_CAP_USER_CONSTANT_BUFFERS);
This->vertex_uploader = This->csmt_active ? This->pipe_secondary->stream_uploader : This->context.pipe->stream_uploader;
- if (!This->driver_caps.user_cbufs)
- This->constbuf_alignment = GET_PCAP(CONSTANT_BUFFER_OFFSET_ALIGNMENT);
This->driver_caps.window_space_position_support = GET_PCAP(TGSI_VS_WINDOW_SPACE_POSITION);
This->driver_caps.vs_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_VERTEX, PIPE_SHADER_CAP_INTEGERS);
This->driver_caps.ps_integer = pScreen->get_shader_param(pScreen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_INTEGERS);
This->driver_caps.offset_units_unscaled = GET_PCAP(POLYGON_OFFSET_UNITS_UNSCALED);
nine_ff_init(This); /* initialize fixed function code */
NineDevice9_SetDefaultState(This, FALSE);
{
diff --git a/src/gallium/state_trackers/nine/device9.h b/src/gallium/state_trackers/nine/device9.h
index c5fd8f7..4cce29a 100644
--- a/src/gallium/state_trackers/nine/device9.h
+++ b/src/gallium/state_trackers/nine/device9.h
@@ -120,35 +120,32 @@ struct NineDevice9
unsigned h;
POINT hotspot; /* -1, -1 if no cursor image set */
POINT pos;
BOOL visible;
boolean software;
void *hw_upload_temp;
} cursor;
struct {
boolean user_vbufs;
- boolean user_cbufs;
boolean user_sw_vbufs;
- boolean user_sw_cbufs;
boolean window_space_position_support;
boolean vs_integer;
boolean ps_integer;
boolean offset_units_unscaled;
} driver_caps;
struct {
boolean buggy_barycentrics;
} driver_bugs;
struct u_upload_mgr *vertex_uploader;
- unsigned constbuf_alignment;
struct nine_range_pool range_pool;
struct hud_context *hud; /* NULL if hud is disabled */
/* dummy vbo (containing 0 0 0 0) to bind if vertex shader input
* is not bound to anything by the vertex declaration */
struct pipe_resource *dummy_vbo;
BOOL device_needs_reset;
int minor_version_num;
diff --git a/src/gallium/state_trackers/nine/nine_ff.c b/src/gallium/state_trackers/nine/nine_ff.c
index 39fcb8b..eb673e4 100644
--- a/src/gallium/state_trackers/nine/nine_ff.c
+++ b/src/gallium/state_trackers/nine/nine_ff.c
@@ -2053,57 +2053,33 @@ nine_ff_update(struct NineDevice9 *device)
nine_ff_load_point_and_fog_params(device);
nine_ff_load_viewport_info(device);
memset(context->ff.changed.transform, 0, sizeof(context->ff.changed.transform));
cb.buffer_offset = 0;
cb.buffer = NULL;
cb.user_buffer = device->ff.vs_const;
cb.buffer_size = NINE_FF_NUM_VS_CONST * 4 * sizeof(float);
- if (!device->driver_caps.user_cbufs) {
- context->pipe_data.cb_vs_ff.buffer_size = cb.buffer_size;
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb.buffer_size,
- device->constbuf_alignment,
- cb.user_buffer,
- &context->pipe_data.cb_vs_ff.buffer_offset,
- &context->pipe_data.cb_vs_ff.buffer);
- u_upload_unmap(device->context.pipe->const_uploader);
- context->pipe_data.cb_vs_ff.user_buffer = NULL;
- } else
- context->pipe_data.cb_vs_ff = cb;
+ context->pipe_data.cb_vs_ff = cb;
context->commit |= NINE_STATE_COMMIT_CONST_VS;
}
if (!context->ps) {
nine_ff_load_ps_params(device);
cb.buffer_offset = 0;
cb.buffer = NULL;
cb.user_buffer = device->ff.ps_const;
cb.buffer_size = NINE_FF_NUM_PS_CONST * 4 * sizeof(float);
- if (!device->driver_caps.user_cbufs) {
- context->pipe_data.cb_ps_ff.buffer_size = cb.buffer_size;
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb.buffer_size,
- device->constbuf_alignment,
- cb.user_buffer,
- &context->pipe_data.cb_ps_ff.buffer_offset,
- &context->pipe_data.cb_ps_ff.buffer);
- u_upload_unmap(device->context.pipe->const_uploader);
- context->pipe_data.cb_ps_ff.user_buffer = NULL;
- } else
- context->pipe_data.cb_ps_ff = cb;
+ context->pipe_data.cb_ps_ff = cb;
context->commit |= NINE_STATE_COMMIT_CONST_PS;
}
context->changed.group &= ~NINE_STATE_FF;
}
boolean
nine_ff_init(struct NineDevice9 *device)
{
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index a9a41af..26b2dea 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -375,23 +375,20 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device)
while (r) {
unsigned p = r->bgn;
unsigned c = r->end - r->bgn;
memcpy(&dst[p * 4], &lconstf->data[n * 4], c * 4 * sizeof(float));
n += c;
r = r->next;
}
cb.user_buffer = dst;
}
- /* Do not erase the buffer field.
- * It is either NULL (user_cbufs), or a resource.
- * u_upload_data will do the proper refcount */
context->pipe_data.cb0_swvp.buffer_offset = cb.buffer_offset;
context->pipe_data.cb0_swvp.buffer_size = cb.buffer_size;
context->pipe_data.cb0_swvp.user_buffer = cb.user_buffer;
cb.user_buffer = (char *)cb.user_buffer + 4096 * sizeof(float[4]);
context->pipe_data.cb1_swvp.buffer_offset = cb.buffer_offset;
context->pipe_data.cb1_swvp.buffer_size = cb.buffer_size;
context->pipe_data.cb1_swvp.user_buffer = cb.user_buffer;
context->changed.vs_const_f = 0;
@@ -416,66 +413,20 @@ prepare_vs_constants_userbuf_swvp(struct NineDevice9 *device)
cb.buffer_offset = 0;
cb.buffer_size = 512 * sizeof(float[4]);
cb.user_buffer = context->vs_const_b;
context->pipe_data.cb3_swvp.buffer_offset = cb.buffer_offset;
context->pipe_data.cb3_swvp.buffer_size = cb.buffer_size;
context->pipe_data.cb3_swvp.user_buffer = cb.user_buffer;
context->changed.vs_const_b = 0;
}
- if (!device->driver_caps.user_cbufs) {
- struct pipe_constant_buffer *cb = &(context->pipe_data.cb0_swvp);
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb->buffer_size,
- device->constbuf_alignment,
- cb->user_buffer,
- &(cb->buffer_offset),
- &(cb->buffer));
- u_upload_unmap(device->context.pipe->const_uploader);
- cb->user_buffer = NULL;
-
- cb = &(context->pipe_data.cb1_swvp);
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb->buffer_size,
- device->constbuf_alignment,
- cb->user_buffer,
- &(cb->buffer_offset),
- &(cb->buffer));
- u_upload_unmap(device->context.pipe->const_uploader);
- cb->user_buffer = NULL;
-
- cb = &(context->pipe_data.cb2_swvp);
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb->buffer_size,
- device->constbuf_alignment,
- cb->user_buffer,
- &(cb->buffer_offset),
- &(cb->buffer));
- u_upload_unmap(device->context.pipe->const_uploader);
- cb->user_buffer = NULL;
-
- cb = &(context->pipe_data.cb3_swvp);
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb->buffer_size,
- device->constbuf_alignment,
- cb->user_buffer,
- &(cb->buffer_offset),
- &(cb->buffer));
- u_upload_unmap(device->context.pipe->const_uploader);
- cb->user_buffer = NULL;
- }
-
context->changed.group &= ~NINE_STATE_VS_CONST;
context->commit |= NINE_STATE_COMMIT_CONST_VS;
}
static void
prepare_vs_constants_userbuf(struct NineDevice9 *device)
{
struct nine_context *context = &device->context;
struct pipe_constant_buffer cb;
cb.buffer = NULL;
@@ -515,34 +466,21 @@ prepare_vs_constants_userbuf(struct NineDevice9 *device)
while (r) {
unsigned p = r->bgn;
unsigned c = r->end - r->bgn;
memcpy(&dst[p * 4], &lconstf->data[n * 4], c * 4 * sizeof(float));
n += c;
r = r->next;
}
cb.user_buffer = dst;
}
- if (!device->driver_caps.user_cbufs) {
- context->pipe_data.cb_vs.buffer_size = cb.buffer_size;
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb.buffer_size,
- device->constbuf_alignment,
- cb.user_buffer,
- &context->pipe_data.cb_vs.buffer_offset,
- &context->pipe_data.cb_vs.buffer);
- u_upload_unmap(device->context.pipe->const_uploader);
- context->pipe_data.cb_vs.user_buffer = NULL;
- } else
- context->pipe_data.cb_vs = cb;
-
+ context->pipe_data.cb_vs = cb;
context->changed.vs_const_f = 0;
context->changed.group &= ~NINE_STATE_VS_CONST;
context->commit |= NINE_STATE_COMMIT_CONST_VS;
}
static void
prepare_ps_constants_userbuf(struct NineDevice9 *device)
{
struct nine_context *context = &device->context;
@@ -586,34 +524,21 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device)
dst[5] = 1.0f / (asfloat(context->rs[D3DRS_FOGEND]) - asfloat(context->rs[D3DRS_FOGSTART]));
} else if (context->rs[D3DRS_FOGTABLEMODE] != D3DFOG_NONE) {
dst[4] = asfloat(context->rs[D3DRS_FOGDENSITY]);
}
cb.buffer_size = 4 * 4 * 34;
}
if (!cb.buffer_size)
return;
- if (!device->driver_caps.user_cbufs) {
- context->pipe_data.cb_ps.buffer_size = cb.buffer_size;
- u_upload_data(device->context.pipe->const_uploader,
- 0,
- cb.buffer_size,
- device->constbuf_alignment,
- cb.user_buffer,
- &context->pipe_data.cb_ps.buffer_offset,
- &context->pipe_data.cb_ps.buffer);
- u_upload_unmap(device->context.pipe->const_uploader);
- context->pipe_data.cb_ps.user_buffer = NULL;
- } else
- context->pipe_data.cb_ps = cb;
-
+ context->pipe_data.cb_ps = cb;
context->changed.ps_const_f = 0;
context->changed.group &= ~NINE_STATE_PS_CONST;
context->commit |= NINE_STATE_COMMIT_CONST_PS;
}
static inline uint32_t
prepare_vs(struct NineDevice9 *device, uint8_t shader_changed)
{
struct nine_context *context = &device->context;
@@ -3341,99 +3266,53 @@ update_vs_constants_sw(struct NineDevice9 *device)
unsigned p = r->bgn;
unsigned c = r->end - r->bgn;
memcpy(&dst[p * 4], &lconstf->data[n * 4], c * 4 * sizeof(float));
n += c;
r = r->next;
}
cb.user_buffer = dst;
}
buf = cb.user_buffer;
- if (!device->driver_caps.user_sw_cbufs) {
- u_upload_data(device->pipe_sw->const_uploader,
- 0,
- cb.buffer_size,
- 16,
- cb.user_buffer,
- &(cb.buffer_offset),
- &(cb.buffer));
- u_upload_unmap(device->pipe_sw->const_uploader);
- cb.user_buffer = NULL;
- }
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 0, &cb);
if (cb.buffer)
pipe_resource_reference(&cb.buffer, NULL);
cb.user_buffer = (char *)buf + 4096 * sizeof(float[4]);
- if (!device->driver_caps.user_sw_cbufs) {
- u_upload_data(device->pipe_sw->const_uploader,
- 0,
- cb.buffer_size,
- 16,
- cb.user_buffer,
- &(cb.buffer_offset),
- &(cb.buffer));
- u_upload_unmap(device->pipe_sw->const_uploader);
- cb.user_buffer = NULL;
- }
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 1, &cb);
if (cb.buffer)
pipe_resource_reference(&cb.buffer, NULL);
}
{
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
cb.buffer_size = 2048 * sizeof(float[4]);
cb.user_buffer = state->vs_const_i;
- if (!device->driver_caps.user_sw_cbufs) {
- u_upload_data(device->pipe_sw->const_uploader,
- 0,
- cb.buffer_size,
- 16,
- cb.user_buffer,
- &(cb.buffer_offset),
- &(cb.buffer));
- u_upload_unmap(device->pipe_sw->const_uploader);
- cb.user_buffer = NULL;
- }
-
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 2, &cb);
if (cb.buffer)
pipe_resource_reference(&cb.buffer, NULL);
}
{
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
cb.buffer_size = 512 * sizeof(float[4]);
cb.user_buffer = state->vs_const_b;
- if (!device->driver_caps.user_sw_cbufs) {
- u_upload_data(device->pipe_sw->const_uploader,
- 0,
- cb.buffer_size,
- 16,
- cb.user_buffer,
- &(cb.buffer_offset),
- &(cb.buffer));
- u_upload_unmap(device->pipe_sw->const_uploader);
- cb.user_buffer = NULL;
- }
-
pipe_sw->set_constant_buffer(pipe_sw, PIPE_SHADER_VERTEX, 3, &cb);
if (cb.buffer)
pipe_resource_reference(&cb.buffer, NULL);
}
{
struct pipe_constant_buffer cb;
const D3DVIEWPORT9 *vport = &device->state.viewport;
float viewport_data[8] = {(float)vport->Width * 0.5f,
(float)vport->Height * -0.5f, vport->MaxZ - vport->MinZ, 0.f,
--
2.7.4
More information about the mesa-dev
mailing list