#include "util/u_helpers.h"
#include "util/u_inlines.h"
#include "util/u_transfer.h"
-#include "util/u_format_srgb.h"
+#include "util/format_srgb.h"
#include "tgsi/tgsi_parse.h"
* ! pipe_rasterizer_state.flatshade_first also applies to QUADS
* (There's a GL query for that, forcing an exception is just ridiculous.)
*
- * ! pipe_rasterizer_state.half_pixel_center is ignored - pixel centers
- * are always at half integer coordinates and the top-left rule applies
- * (There does not seem to be a hardware switch for this.)
- *
* ! pipe_rasterizer_state.sprite_coord_enable is masked with 0xff on NVC0
* (The hardware only has 8 slots meant for TexCoord and we have to assign
* in advance to maintain elegant separate shader objects.)
*/
-static INLINE uint32_t
+static inline uint32_t
nv50_colormask(unsigned mask)
{
uint32_t ret = 0;
}
#define NV50_BLEND_FACTOR_CASE(a, b) \
- case PIPE_BLENDFACTOR_##a: return NV50_3D_BLEND_FACTOR_##b
+ case PIPE_BLENDFACTOR_##a: return NV50_BLEND_FACTOR_##b
-static INLINE uint32_t
+static inline uint32_t
nv50_blend_fac(unsigned factor)
{
switch (factor) {
NV50_BLEND_FACTOR_CASE(INV_SRC1_COLOR, ONE_MINUS_SRC1_COLOR);
NV50_BLEND_FACTOR_CASE(INV_SRC1_ALPHA, ONE_MINUS_SRC1_ALPHA);
default:
- return NV50_3D_BLEND_FACTOR_ZERO;
+ return NV50_BLEND_FACTOR_ZERO;
}
}
{
struct nv50_blend_stateobj *so = CALLOC_STRUCT(nv50_blend_stateobj);
int i;
- boolean emit_common_func = cso->rt[0].blend_enable;
+ bool emit_common_func = cso->rt[0].blend_enable;
uint32_t ms;
if (nv50_context(pipe)->screen->tesla->oclass >= NVA3_3D_CLASS) {
for (i = 0; i < 8; ++i) {
SB_DATA(so, cso->rt[i].blend_enable);
if (cso->rt[i].blend_enable)
- emit_common_func = TRUE;
+ emit_common_func = true;
}
if (nv50_context(pipe)->screen->tesla->oclass >= NVA3_3D_CLASS) {
- emit_common_func = FALSE;
+ emit_common_func = false;
for (i = 0; i < 8; ++i) {
if (!cso->rt[i].blend_enable)
FREE(hwcso);
}
-/* NOTE: ignoring line_last_pixel, using FALSE (set on screen init) */
+/* NOTE: ignoring line_last_pixel */
static void *
nv50_rasterizer_state_create(struct pipe_context *pipe,
const struct pipe_rasterizer_state *cso)
so->pipe = *cso;
#ifndef NV50_SCISSORS_CLIPPING
- SB_BEGIN_3D(so, SCISSOR_ENABLE(0), 1);
- SB_DATA (so, cso->scissor);
+ for (int i = 0; i < NV50_MAX_VIEWPORTS; i++) {
+ SB_BEGIN_3D(so, SCISSOR_ENABLE(i), 1);
+ SB_DATA (so, cso->scissor);
+ }
#endif
SB_BEGIN_3D(so, SHADE_MODEL, 1);
SB_BEGIN_3D(so, VIEW_VOLUME_CLIP_CTRL, 1);
SB_DATA (so, reg);
+ SB_BEGIN_3D(so, DEPTH_CLIP_NEGATIVE_Z, 1);
+ SB_DATA (so, cso->clip_halfz);
+
+ SB_BEGIN_3D(so, PIXEL_CENTER_INTEGER, 1);
+ SB_DATA (so, !cso->half_pixel_center);
+
assert(so->size <= (sizeof(so->state) / sizeof(so->state[0])));
return (void *)so;
}
#define NV50_TSC_WRAP_CASE(n) \
case PIPE_TEX_WRAP_##n: return NV50_TSC_WRAP_##n
-static INLINE unsigned
+static inline unsigned
nv50_tsc_wrap_mode(unsigned wrap)
{
switch (wrap) {
{
unsigned s, i;
- for (s = 0; s < 3; ++s)
+ for (s = 0; s < 3; ++s) {
+ assert(nv50_context(pipe)->num_samplers[s] <= PIPE_MAX_SAMPLERS);
for (i = 0; i < nv50_context(pipe)->num_samplers[s]; ++i)
if (nv50_context(pipe)->samplers[s][i] == hwcso)
nv50_context(pipe)->samplers[s][i] = NULL;
+ }
nv50_screen_tsc_free(nv50_context(pipe)->screen, nv50_tsc_entry(hwcso));
FREE(hwcso);
}
-static INLINE void
+static inline void
nv50_stage_sampler_states_bind(struct nv50_context *nv50, int s,
unsigned nr, void **hwcso)
{
unsigned i;
+ assert(nr <= PIPE_MAX_SAMPLERS);
for (i = 0; i < nr; ++i) {
struct nv50_tsc_entry *old = nv50->samplers[s][i];
if (old)
nv50_screen_tsc_unlock(nv50->screen, old);
}
- for (; i < nv50->num_samplers[s]; ++i)
- if (nv50->samplers[s][i])
+ assert(nv50->num_samplers[s] <= PIPE_MAX_SAMPLERS);
+ for (; i < nv50->num_samplers[s]; ++i) {
+ if (nv50->samplers[s][i]) {
nv50_screen_tsc_unlock(nv50->screen, nv50->samplers[s][i]);
+ nv50->samplers[s][i] = NULL;
+ }
+ }
nv50->num_samplers[s] = nr;
FREE(nv50_tic_entry(view));
}
-static INLINE void
+static inline void
nv50_stage_set_sampler_views(struct nv50_context *nv50, int s,
unsigned nr,
struct pipe_sampler_view **views)
{
unsigned i;
+ assert(nr <= PIPE_MAX_SAMPLERS);
for (i = 0; i < nr; ++i) {
struct nv50_tic_entry *old = nv50_tic_entry(nv50->textures[s][i]);
if (old)
pipe_sampler_view_reference(&nv50->textures[s][i], views[i]);
}
+ assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS);
for (i = nr; i < nv50->num_textures[s]; ++i) {
struct nv50_tic_entry *old = nv50_tic_entry(nv50->textures[s][i]);
if (!old)
if (shader == PIPE_SHADER_COMPUTE)
return;
+ assert(i < NV50_MAX_PIPE_CONSTBUFS);
if (nv50->constbuf[s][i].user)
nv50->constbuf[s][i].u.buf = NULL;
else
pipe_resource_reference(&nv50->constbuf[s][i].u.buf, res);
- nv50->constbuf[s][i].user = (cb && cb->user_buffer) ? TRUE : FALSE;
+ nv50->constbuf[s][i].user = (cb && cb->user_buffer) ? true : false;
if (nv50->constbuf[s][i].user) {
nv50->constbuf[s][i].u.data = cb->user_buffer;
- nv50->constbuf[s][i].size = cb->buffer_size;
+ nv50->constbuf[s][i].size = MIN2(cb->buffer_size, 0x10000);
nv50->constbuf_valid[s] |= 1 << i;
} else
if (res) {
nv50->constbuf[s][i].offset = cb->buffer_offset;
- nv50->constbuf[s][i].size = align(cb->buffer_size, 0x100);
+ nv50->constbuf[s][i].size = MIN2(align(cb->buffer_size, 0x100), 0x10000);
nv50->constbuf_valid[s] |= 1 << i;
} else {
nv50->constbuf_valid[s] &= ~(1 << i);
nv50->dirty |= NV50_NEW_SAMPLE_MASK;
}
+static void
+nv50_set_min_samples(struct pipe_context *pipe, unsigned min_samples)
+{
+ struct nv50_context *nv50 = nv50_context(pipe);
+
+ if (nv50->min_samples != min_samples) {
+ nv50->min_samples = min_samples;
+ nv50->dirty |= NV50_NEW_MIN_SAMPLES;
+ }
+}
static void
nv50_set_framebuffer_state(struct pipe_context *pipe,
const struct pipe_scissor_state *scissor)
{
struct nv50_context *nv50 = nv50_context(pipe);
+ int i;
- nv50->scissor = *scissor;
- nv50->dirty |= NV50_NEW_SCISSOR;
+ assert(start_slot + num_scissors <= NV50_MAX_VIEWPORTS);
+ for (i = 0; i < num_scissors; i++) {
+ if (!memcmp(&nv50->scissors[start_slot + i], &scissor[i], sizeof(*scissor)))
+ continue;
+ nv50->scissors[start_slot + i] = scissor[i];
+ nv50->scissors_dirty |= 1 << (start_slot + i);
+ nv50->dirty |= NV50_NEW_SCISSOR;
+ }
}
static void
const struct pipe_viewport_state *vpt)
{
struct nv50_context *nv50 = nv50_context(pipe);
+ int i;
- nv50->viewport = *vpt;
- nv50->dirty |= NV50_NEW_VIEWPORT;
+ assert(start_slot + num_viewports <= NV50_MAX_VIEWPORTS);
+ for (i = 0; i < num_viewports; i++) {
+ if (!memcmp(&nv50->viewports[start_slot + i], &vpt[i], sizeof(*vpt)))
+ continue;
+ nv50->viewports[start_slot + i] = vpt[i];
+ nv50->viewports_dirty |= 1 << (start_slot + i);
+ nv50->dirty |= NV50_NEW_VIEWPORT;
+ }
}
static void
struct pipe_resource *res,
unsigned offset, unsigned size)
{
+ struct nv04_resource *buf = (struct nv04_resource *)res;
struct nv50_so_target *targ = MALLOC_STRUCT(nv50_so_target);
if (!targ)
return NULL;
if (nouveau_context(pipe)->screen->class_3d >= NVA0_3D_CLASS) {
targ->pq = pipe->create_query(pipe,
- NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET);
+ NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET, 0);
if (!targ->pq) {
FREE(targ);
return NULL;
} else {
targ->pq = NULL;
}
- targ->clean = TRUE;
+ targ->clean = true;
targ->pipe.buffer_size = size;
targ->pipe.buffer_offset = offset;
pipe_resource_reference(&targ->pipe.buffer, res);
pipe_reference_init(&targ->pipe.reference, 1);
+ assert(buf->base.target == PIPE_BUFFER);
+ util_range_add(&buf->valid_buffer_range, offset, offset + size);
+
return &targ->pipe;
}
nv50_set_stream_output_targets(struct pipe_context *pipe,
unsigned num_targets,
struct pipe_stream_output_target **targets,
- unsigned append_mask)
+ const unsigned *offsets)
{
struct nv50_context *nv50 = nv50_context(pipe);
unsigned i;
- boolean serialize = TRUE;
- const boolean can_resume = nv50->screen->base.class_3d >= NVA0_3D_CLASS;
+ bool serialize = true;
+ const bool can_resume = nv50->screen->base.class_3d >= NVA0_3D_CLASS;
assert(num_targets <= 4);
for (i = 0; i < num_targets; ++i) {
- const boolean changed = nv50->so_target[i] != targets[i];
- if (!changed && (append_mask & (1 << i)))
+ const bool changed = nv50->so_target[i] != targets[i];
+ const bool append = (offsets[i] == (unsigned)-1);
+ if (!changed && append)
continue;
nv50->so_targets_dirty |= 1 << i;
if (can_resume && changed && nv50->so_target[i]) {
nva0_so_target_save_offset(pipe, nv50->so_target[i], i, serialize);
- serialize = FALSE;
+ serialize = false;
}
- if (targets[i] && !(append_mask & (1 << i)))
- nv50_so_target(targets[i])->clean = TRUE;
+ if (targets[i] && !append)
+ nv50_so_target(targets[i])->clean = true;
pipe_so_target_reference(&nv50->so_target[i], targets[i]);
}
for (; i < nv50->num_so_targets; ++i) {
if (can_resume && nv50->so_target[i]) {
nva0_so_target_save_offset(pipe, nv50->so_target[i], i, serialize);
- serialize = FALSE;
+ serialize = false;
}
pipe_so_target_reference(&nv50->so_target[i], NULL);
nv50->so_targets_dirty |= 1 << i;
pipe->set_stencil_ref = nv50_set_stencil_ref;
pipe->set_clip_state = nv50_set_clip_state;
pipe->set_sample_mask = nv50_set_sample_mask;
+ pipe->set_min_samples = nv50_set_min_samples;
pipe->set_constant_buffer = nv50_set_constant_buffer;
pipe->set_framebuffer_state = nv50_set_framebuffer_state;
pipe->set_polygon_stipple = nv50_set_polygon_stipple;
pipe->create_stream_output_target = nv50_so_target_create;
pipe->stream_output_target_destroy = nv50_so_target_destroy;
pipe->set_stream_output_targets = nv50_set_stream_output_targets;
+
+ nv50->sample_mask = ~0;
+ nv50->min_samples = 1;
}