#include "util/u_inlines.h"
#include "util/u_helpers.h"
#include "util/u_framebuffer.h"
+#include "util/u_viewport.h"
#include "swr_state.h"
#include "swr_context.h"
static void
swr_bind_sampler_states(struct pipe_context *pipe,
- unsigned shader,
+ enum pipe_shader_type shader,
unsigned start,
unsigned num,
void **samplers)
static void
swr_set_sampler_views(struct pipe_context *pipe,
- unsigned shader,
+ enum pipe_shader_type shader,
unsigned start,
unsigned num,
struct pipe_sampler_view **views)
rastState->depthFormat = swr_resource(zb->texture)->swr.format;
rastState->depthClipEnable = rasterizer->depth_clip;
+ rastState->clipHalfZ = rasterizer->clip_halfz;
rastState->clipDistanceMask =
ctx->vs->info.base.num_written_clipdistance ?
vp->width = state->translate[0] + state->scale[0];
vp->y = state->translate[1] - fabs(state->scale[1]);
vp->height = state->translate[1] + fabs(state->scale[1]);
- if (rasterizer->clip_halfz == 0) {
- vp->minZ = state->translate[2] - state->scale[2];
- vp->maxZ = state->translate[2] + state->scale[2];
- } else {
- vp->minZ = state->translate[2];
- vp->maxZ = state->translate[2] + state->scale[2];
- }
+ util_viewport_zmin_zmax(state, rasterizer->clip_halfz,
+ &vp->minZ, &vp->maxZ);
vpm->m00[0] = state->scale[0];
vpm->m11[0] = state->scale[1];
struct pipe_depth_state *depth = &(ctx->depth_stencil->depth);
struct pipe_stencil_state *stencil = ctx->depth_stencil->stencil;
SWR_DEPTH_STENCIL_STATE depthStencilState = {{0}};
+ SWR_DEPTH_BOUNDS_STATE depthBoundsState = {0};
/* XXX, incomplete. Need to flesh out stencil & alpha test state
struct pipe_stencil_state *front_stencil =
depthStencilState.depthTestFunc = swr_convert_depth_func(depth->func);
depthStencilState.depthWriteEnable = depth->writemask;
SwrSetDepthStencilState(ctx->swrContext, &depthStencilState);
+
+ depthBoundsState.depthBoundsTestEnable = depth->bounds_test;
+ depthBoundsState.depthBoundsTestMinValue = depth->bounds_min;
+ depthBoundsState.depthBoundsTestMaxValue = depth->bounds_max;
+ SwrSetDepthBoundsState(ctx->swrContext, &depthBoundsState);
}
/* Blend State */
&ctx->blend->compileState[target],
sizeof(compileState.blendState));
+ const SWR_FORMAT_INFO& info = GetFormatInfo(compileState.format);
+ if (compileState.blendState.logicOpEnable &&
+ ((info.type[0] == SWR_TYPE_FLOAT) || info.isSRGB)) {
+ compileState.blendState.logicOpEnable = false;
+ }
+
if (compileState.blendState.blendEnable == false &&
- compileState.blendState.logicOpEnable == false) {
+ compileState.blendState.logicOpEnable == false &&
+ ctx->depth_stencil->alpha.enabled == 0) {
SwrSetBlendFunc(ctx->swrContext, target, NULL);
continue;
}
compileState.desc.alphaTestEnable =
ctx->depth_stencil->alpha.enabled;
compileState.desc.independentAlphaBlendEnable =
- ctx->blend->pipe.independent_blend_enable;
+ (compileState.blendState.sourceBlendFactor !=
+ compileState.blendState.sourceAlphaBlendFactor) ||
+ (compileState.blendState.destBlendFactor !=
+ compileState.blendState.destAlphaBlendFactor) ||
+ (compileState.blendState.colorBlendFunc !=
+ compileState.blendState.alphaBlendFunc);
compileState.desc.alphaToCoverageEnable =
ctx->blend->pipe.alpha_to_coverage;
compileState.desc.sampleMaskEnable = 0; // XXX
swr_convert_depth_func(ctx->depth_stencil->alpha.func);
compileState.alphaTestFormat = ALPHA_TEST_FLOAT32; // xxx
+ compileState.Canonicalize();
+
PFN_BLEND_JIT_FUNC func = NULL;
auto search = ctx->blendJIT->find(compileState);
if (search != ctx->blendJIT->end()) {