#define DBG_CHANNEL DBG_DEVICE
+/* Check if some states need to be set dirty */
+
+static inline DWORD
+check_multisample(struct NineDevice9 *device)
+{
+ DWORD *rs = device->state.rs;
+ DWORD new_value = (rs[D3DRS_ZENABLE] || rs[D3DRS_STENCILENABLE]) &&
+ device->state.rt[0]->desc.MultiSampleType >= 1 &&
+ rs[D3DRS_MULTISAMPLEANTIALIAS];
+ if (rs[NINED3DRS_MULTISAMPLE] != new_value) {
+ rs[NINED3DRS_MULTISAMPLE] = new_value;
+ return NINE_STATE_RASTERIZER;
+ }
+ return 0;
+}
+
/* State preparation only */
static inline void
NINE_STATE_TEXTURE | \
NINE_STATE_SAMPLER | \
NINE_STATE_VS_CONST | \
- NINE_STATE_PS_CONST)
+ NINE_STATE_PS_CONST | \
+ NINE_STATE_MULTISAMPLE)
#define NINE_STATE_COMMON \
(NINE_STATE_FB | \
}
if (likely(group & (NINE_STATE_FREQUENT | NINE_STATE_VS | NINE_STATE_PS))) {
+ if (group & NINE_STATE_MULTISAMPLE)
+ group |= check_multisample(device);
if (group & NINE_STATE_RASTERIZER)
prepare_rasterizer(device);
if (group & (NINE_STATE_TEXTURE | NINE_STATE_SAMPLER))
[D3DRS_BLENDOPALPHA] = D3DBLENDOP_ADD,
[NINED3DRS_VSPOINTSIZE] = FALSE,
[NINED3DRS_RTMASK] = 0xf,
- [NINED3DRS_ALPHACOVERAGE] = FALSE
+ [NINED3DRS_ALPHACOVERAGE] = FALSE,
+ [NINED3DRS_MULTISAMPLE] = FALSE
};
static const DWORD nine_tex_stage_state_defaults[NINED3DTSS_LAST + 1] =
{
/* TODO: put in the right values */
const uint32_t nine_render_state_group[NINED3DRS_LAST + 1] =
{
- [D3DRS_ZENABLE] = NINE_STATE_DSA,
+ [D3DRS_ZENABLE] = NINE_STATE_DSA | NINE_STATE_MULTISAMPLE,
[D3DRS_FILLMODE] = NINE_STATE_RASTERIZER,
[D3DRS_SHADEMODE] = NINE_STATE_RASTERIZER,
[D3DRS_ZWRITEENABLE] = NINE_STATE_DSA,
[D3DRS_FOGEND] = NINE_STATE_FF_OTHER | NINE_STATE_PS_CONST,
[D3DRS_FOGDENSITY] = NINE_STATE_FF_OTHER | NINE_STATE_PS_CONST,
[D3DRS_RANGEFOGENABLE] = NINE_STATE_FF_OTHER,
- [D3DRS_STENCILENABLE] = NINE_STATE_DSA,
+ [D3DRS_STENCILENABLE] = NINE_STATE_DSA | NINE_STATE_MULTISAMPLE,
[D3DRS_STENCILFAIL] = NINE_STATE_DSA,
[D3DRS_STENCILZFAIL] = NINE_STATE_DSA,
[D3DRS_STENCILPASS] = NINE_STATE_DSA,
[D3DRS_POINTSCALE_A] = NINE_STATE_FF_OTHER,
[D3DRS_POINTSCALE_B] = NINE_STATE_FF_OTHER,
[D3DRS_POINTSCALE_C] = NINE_STATE_FF_OTHER,
- [D3DRS_MULTISAMPLEANTIALIAS] = NINE_STATE_RASTERIZER,
+ [D3DRS_MULTISAMPLEANTIALIAS] = NINE_STATE_MULTISAMPLE,
[D3DRS_MULTISAMPLEMASK] = NINE_STATE_SAMPLE_MASK,
[D3DRS_PATCHEDGESTYLE] = NINE_STATE_UNHANDLED,
[D3DRS_DEBUGMONITORTOKEN] = NINE_STATE_UNHANDLED,
* bit 1: ATOC is on
*/
#define NINED3DRS_ALPHACOVERAGE (D3DRS_BLENDOPALPHA + 3)
+#define NINED3DRS_MULTISAMPLE (D3DRS_BLENDOPALPHA + 4)
#define D3DRS_LAST D3DRS_BLENDOPALPHA
-#define NINED3DRS_LAST NINED3DRS_ALPHACOVERAGE /* 213 */
+#define NINED3DRS_LAST NINED3DRS_MULTISAMPLE /* 214 */
#define NINED3DSAMP_LAST NINED3DSAMP_SHADOW /* 15 */
#define NINED3DTSS_LAST D3DTSS_CONSTANT
#define NINED3DTS_LAST D3DTS_WORLDMATRIX(255)
#define NINE_STATE_FOG_SHADER (1 << 25)
#define NINE_STATE_PS1X_SHADER (1 << 26)
#define NINE_STATE_POINTSIZE_SHADER (1 << 27)
-#define NINE_STATE_ALL 0xfffffff
-#define NINE_STATE_UNHANDLED (1 << 28)
+#define NINE_STATE_MULTISAMPLE (1 << 28)
+#define NINE_STATE_ALL 0x1fffffff
+#define NINE_STATE_UNHANDLED (1 << 29)
#define NINE_STATE_COMMIT_DSA (1 << 0)
#define NINE_STATE_COMMIT_RASTERIZER (1 << 1)