mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
r300: Add blend state.
Also switched to r300_reg instead of radeon_reg. Yay?
This commit is contained in:
parent
432ab001d0
commit
74288078ea
6 changed files with 3401 additions and 4 deletions
|
|
@ -35,7 +35,7 @@ int r300_fill_blit(struct r300_context* r300,
|
|||
{
|
||||
CS_LOCALS(r300);
|
||||
uint32_t dest_type;
|
||||
|
||||
#if 0
|
||||
/* Check for fallbacks. */
|
||||
/* XXX we can do YUV surfaces, too, but only in 3D mode. Hmm... */
|
||||
switch(cpp) {
|
||||
|
|
@ -91,6 +91,6 @@ int r300_fill_blit(struct r300_context* r300,
|
|||
RADEON_WAIT_2D_IDLECLEAN | RADEON_WAIT_DMA_GUI_IDLE);
|
||||
|
||||
END_CS;
|
||||
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,15 @@
|
|||
#include "pipe/p_context.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
struct r300_blend_state {
|
||||
uint32_t blend_control; /* R300_RB3D_BLENDCNTL: 0x4e04 */
|
||||
uint32_t alpha_blend_control; /* R300_RB3D_ABLENDCNTL: 0x4e08 */
|
||||
uint32_t rop; /* R300_RB3D_ROPCNTL: 0x4e18 */
|
||||
uint32_t dither; /* R300_RB3D_DITHER_CTL: 0x4e50 */
|
||||
};
|
||||
|
||||
#define R300_NEW_BLEND 0x1
|
||||
|
||||
struct r300_context {
|
||||
/* Parent class */
|
||||
struct pipe_context context;
|
||||
|
|
@ -35,6 +44,13 @@ struct r300_context {
|
|||
struct r300_winsys* winsys;
|
||||
/* Draw module. Used mostly for SW TCL. */
|
||||
struct draw_context* draw;
|
||||
|
||||
/* Various CSO state objects. */
|
||||
/* Blend state. */
|
||||
struct r300_blend_state* blend_state;
|
||||
|
||||
/* Bitmask of dirty state objects. */
|
||||
uint32_t dirty_state;
|
||||
};
|
||||
|
||||
/* Convenience cast wrapper. */
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@
|
|||
#ifndef R300_CS_H
|
||||
#define R300_CS_H
|
||||
|
||||
#include "radeon_reg.h"
|
||||
|
||||
#include "r300_reg.h"
|
||||
#include "r300_winsys.h"
|
||||
|
||||
/* Yes, I know macros are ugly. However, they are much prettier than the code
|
||||
|
|
|
|||
3259
src/gallium/drivers/r300/r300_reg.h
Normal file
3259
src/gallium/drivers/r300/r300_reg.h
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -21,6 +21,127 @@
|
|||
* USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
|
||||
#include "r300_context.h"
|
||||
#include "r300_state.h"
|
||||
|
||||
static uint32_t translate_blend_function(int blend_func) {
|
||||
switch (blend_func) {
|
||||
case PIPE_BLEND_ADD:
|
||||
return R300_COMB_FCN_ADD_CLAMP;
|
||||
case PIPE_BLEND_SUBTRACT:
|
||||
return R300_COMB_FCN_SUB_CLAMP;
|
||||
case PIPE_BLEND_REVERSE_SUBTRACT:
|
||||
return R300_COMB_FCN_RSUB_CLAMP;
|
||||
case PIPE_BLEND_MIN:
|
||||
return R300_COMB_FCN_MIN;
|
||||
case PIPE_BLEND_MAX:
|
||||
return R300_COMB_FCN_MAX;
|
||||
default:
|
||||
/* XXX should be unreachable, handle this */
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* XXX we can also offer the D3D versions of some of these... */
|
||||
static uint32_t translate_blend_factor(int blend_fact) {
|
||||
switch (blend_fact) {
|
||||
case PIPE_BLENDFACTOR_ONE:
|
||||
return R300_BLEND_GL_ONE;
|
||||
case PIPE_BLENDFACTOR_SRC_COLOR:
|
||||
return R300_BLEND_GL_SRC_COLOR;
|
||||
case PIPE_BLENDFACTOR_SRC_ALPHA:
|
||||
return R300_BLEND_GL_SRC_ALPHA;
|
||||
case PIPE_BLENDFACTOR_DST_ALPHA:
|
||||
return R300_BLEND_GL_DST_ALPHA;
|
||||
case PIPE_BLENDFACTOR_DST_COLOR:
|
||||
return R300_BLEND_GL_DST_COLOR;
|
||||
case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
|
||||
return R300_BLEND_GL_SRC_ALPHA_SATURATE;
|
||||
case PIPE_BLENDFACTOR_CONST_COLOR:
|
||||
return R300_BLEND_GL_CONST_COLOR;
|
||||
case PIPE_BLENDFACTOR_CONST_ALPHA:
|
||||
return R300_BLEND_GL_CONST_ALPHA;
|
||||
/* XXX WTF are these?
|
||||
case PIPE_BLENDFACTOR_SRC1_COLOR:
|
||||
case PIPE_BLENDFACTOR_SRC1_ALPHA: */
|
||||
case PIPE_BLENDFACTOR_ZERO:
|
||||
return R300_BLEND_GL_ZERO;
|
||||
case PIPE_BLENDFACTOR_INV_SRC_COLOR:
|
||||
return R300_BLEND_GL_ONE_MINUS_SRC_COLOR;
|
||||
case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
|
||||
return R300_BLEND_GL_ONE_MINUS_SRC_ALPHA;
|
||||
case PIPE_BLENDFACTOR_INV_DST_ALPHA:
|
||||
return R300_BLEND_GL_ONE_MINUS_DST_ALPHA;
|
||||
case PIPE_BLENDFACTOR_INV_DST_COLOR:
|
||||
return R300_BLEND_GL_ONE_MINUS_DST_COLOR;
|
||||
case PIPE_BLENDFACTOR_INV_CONST_COLOR:
|
||||
return R300_BLEND_GL_ONE_MINUS_CONST_COLOR;
|
||||
case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
|
||||
return R300_BLEND_GL_ONE_MINUS_CONST_ALPHA;
|
||||
/* XXX see above
|
||||
case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
|
||||
case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */
|
||||
default:
|
||||
/* XXX the mythical 0x16 blend factor! */
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void* r300_create_blend_state(struct pipe_context* pipe,
|
||||
struct pipe_blend_state* state)
|
||||
{
|
||||
struct r300_blend_state* blend = CALLOC_STRUCT(r300_blend_state);
|
||||
|
||||
if (state->blend_enable) {
|
||||
/* XXX for now, always do separate alpha...
|
||||
* is it faster to do it with one reg? */
|
||||
blend->blend_control = R300_ALPHA_BLEND_ENABLE |
|
||||
R300_SEPARATE_ALPHA_ENABLE |
|
||||
R300_READ_ENABLE |
|
||||
translate_blend_function(state->rgb_func) |
|
||||
(translate_blend_factor(state->rgb_src_factor) <<
|
||||
R300_SRC_BLEND_SHIFT) |
|
||||
(translate_blend_factor(state->rgb_dst_factor) <<
|
||||
R300_DST_BLEND_SHIFT);
|
||||
blend->alpha_blend_control =
|
||||
translate_blend_function(state->alpha_func) |
|
||||
(translate_blend_factor(state->alpha_src_factor) <<
|
||||
R300_SRC_BLEND_SHIFT) |
|
||||
(translate_blend_factor(state->alpha_dst_factor) <<
|
||||
R300_DST_BLEND_SHIFT);
|
||||
}
|
||||
|
||||
/* PIPE_LOGICOP_* don't need to be translated, fortunately. */
|
||||
/* XXX are logicops still allowed if blending's disabled?
|
||||
* Does Gallium take care of it for us? */
|
||||
if (state->logicop_enable) {
|
||||
blend->rop = R300_RB3D_ROPCNTL_ROP_ENABLE |
|
||||
(state->logicop_func) << R300_RB3D_ROPCNTL_ROP_SHIFT;
|
||||
}
|
||||
|
||||
if (state->dither) {
|
||||
blend->dither = R300_RB3D_DITHER_CTL_DITHER_MODE_LUT |
|
||||
R300_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_LUT;
|
||||
}
|
||||
|
||||
return (void*)blend;
|
||||
}
|
||||
|
||||
static void r300_bind_blend_state(struct pipe_context* pipe,
|
||||
void* state)
|
||||
{
|
||||
struct r300_context* r300 = r300_context(pipe);
|
||||
|
||||
r300->blend_state = (struct r300_blend_state*)state;
|
||||
r300->dirty_state |= R300_NEW_BLEND;
|
||||
}
|
||||
|
||||
static void r300_delete_blend_state(struct pipe_context* pipe,
|
||||
void* state)
|
||||
{
|
||||
FREE(state);
|
||||
}
|
||||
|
||||
static void* r300_create_vs_state(struct pipe_context* pipe,
|
||||
struct pipe_shader_state* state)
|
||||
|
|
|
|||
|
|
@ -23,4 +23,6 @@
|
|||
#ifndef R300_STATE_H
|
||||
#define R300_STATE_H
|
||||
|
||||
#include "r300_reg.h"
|
||||
|
||||
#endif /* R300_STATE_H */
|
||||
Loading…
Add table
Reference in a new issue