GPUState: Fix signed / bitfield conversion leading to wrong enum value
This was creating drawing issues on windows builds.
This commit is contained in:
@@ -44,7 +44,7 @@ using namespace blender::gpu;
|
||||
do { \
|
||||
GPUStateManager *stack = GPU_context_active_get()->state_manager; \
|
||||
auto &state_object = stack->_prefix##state; \
|
||||
state_object._state = _value; \
|
||||
state_object._state = (_value); \
|
||||
} while (0)
|
||||
|
||||
#define SET_IMMUTABLE_STATE(_state, _value) SET_STATE(, _state, _value)
|
||||
@@ -104,11 +104,11 @@ void GPU_color_mask(bool r, bool g, bool b, bool a)
|
||||
{
|
||||
GPUStateManager *stack = GPU_context_active_get()->state_manager;
|
||||
auto &state = stack->state;
|
||||
eGPUWriteMask write_mask = state.write_mask;
|
||||
SET_FLAG_FROM_TEST(write_mask, r, GPU_WRITE_RED);
|
||||
SET_FLAG_FROM_TEST(write_mask, g, GPU_WRITE_GREEN);
|
||||
SET_FLAG_FROM_TEST(write_mask, b, GPU_WRITE_BLUE);
|
||||
SET_FLAG_FROM_TEST(write_mask, a, GPU_WRITE_ALPHA);
|
||||
uint32_t write_mask = state.write_mask;
|
||||
SET_FLAG_FROM_TEST(write_mask, r, (uint32_t)GPU_WRITE_RED);
|
||||
SET_FLAG_FROM_TEST(write_mask, g, (uint32_t)GPU_WRITE_GREEN);
|
||||
SET_FLAG_FROM_TEST(write_mask, b, (uint32_t)GPU_WRITE_BLUE);
|
||||
SET_FLAG_FROM_TEST(write_mask, a, (uint32_t)GPU_WRITE_ALPHA);
|
||||
state.write_mask = write_mask;
|
||||
}
|
||||
|
||||
@@ -116,8 +116,8 @@ void GPU_depth_mask(bool depth)
|
||||
{
|
||||
GPUStateManager *stack = GPU_context_active_get()->state_manager;
|
||||
auto &state = stack->state;
|
||||
eGPUWriteMask write_mask = state.write_mask;
|
||||
SET_FLAG_FROM_TEST(write_mask, depth, GPU_WRITE_DEPTH);
|
||||
uint32_t write_mask = state.write_mask;
|
||||
SET_FLAG_FROM_TEST(write_mask, depth, (uint32_t)GPU_WRITE_DEPTH);
|
||||
state.write_mask = write_mask;
|
||||
}
|
||||
|
||||
@@ -141,13 +141,13 @@ void GPU_state_set(eGPUWriteMask write_mask,
|
||||
{
|
||||
GPUStateManager *stack = GPU_context_active_get()->state_manager;
|
||||
auto &state = stack->state;
|
||||
state.write_mask = write_mask;
|
||||
state.blend = blend;
|
||||
state.culling_test = culling_test;
|
||||
state.depth_test = depth_test;
|
||||
state.stencil_test = stencil_test;
|
||||
state.stencil_op = stencil_op;
|
||||
state.provoking_vert = provoking_vert;
|
||||
state.write_mask = (uint32_t)write_mask;
|
||||
state.blend = (uint32_t)blend;
|
||||
state.culling_test = (uint32_t)culling_test;
|
||||
state.depth_test = (uint32_t)depth_test;
|
||||
state.stencil_test = (uint32_t)stencil_test;
|
||||
state.stencil_op = (uint32_t)stencil_op;
|
||||
state.provoking_vert = (uint32_t)provoking_vert;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -231,13 +231,13 @@ void GPU_stencil_compare_mask_set(uint compare_mask)
|
||||
eGPUBlend GPU_blend_get()
|
||||
{
|
||||
GPUState &state = GPU_context_active_get()->state_manager->state;
|
||||
return state.blend;
|
||||
return (eGPUBlend)state.blend;
|
||||
}
|
||||
|
||||
eGPUWriteMask GPU_write_mask_get()
|
||||
{
|
||||
GPUState &state = GPU_context_active_get()->state_manager->state;
|
||||
return state.write_mask;
|
||||
return (eGPUWriteMask)state.write_mask;
|
||||
}
|
||||
|
||||
bool GPU_depth_test_enabled()
|
||||
|
||||
@@ -35,13 +35,20 @@ namespace gpu {
|
||||
* Try to keep small to reduce validation time. */
|
||||
union GPUState {
|
||||
struct {
|
||||
eGPUWriteMask write_mask : 13;
|
||||
eGPUBlend blend : 4;
|
||||
eGPUFaceCullTest culling_test : 2;
|
||||
eGPUDepthTest depth_test : 3;
|
||||
eGPUStencilTest stencil_test : 3;
|
||||
eGPUStencilOp stencil_op : 3;
|
||||
eGPUProvokingVertex provoking_vert : 1;
|
||||
/** eGPUWriteMask */
|
||||
uint32_t write_mask : 13;
|
||||
/** eGPUBlend */
|
||||
uint32_t blend : 4;
|
||||
/** eGPUFaceCullTest */
|
||||
uint32_t culling_test : 2;
|
||||
/** eGPUDepthTest */
|
||||
uint32_t depth_test : 3;
|
||||
/** eGPUStencilTest */
|
||||
uint32_t stencil_test : 3;
|
||||
/** eGPUStencilOp */
|
||||
uint32_t stencil_op : 3;
|
||||
/** eGPUProvokingVertex */
|
||||
uint32_t provoking_vert : 1;
|
||||
/** Enable bits. */
|
||||
uint32_t logic_op_xor : 1;
|
||||
uint32_t invert_facing : 1;
|
||||
|
||||
@@ -65,23 +65,23 @@ void GLStateManager::set_state(const GPUState &state)
|
||||
GPUState changed = state ^ current_;
|
||||
|
||||
if (changed.blend != 0) {
|
||||
set_blend(state.blend);
|
||||
set_blend((eGPUBlend)state.blend);
|
||||
}
|
||||
if (changed.write_mask != 0) {
|
||||
set_write_mask(state.write_mask);
|
||||
set_write_mask((eGPUWriteMask)state.write_mask);
|
||||
}
|
||||
if (changed.depth_test != 0) {
|
||||
set_depth_test(state.depth_test);
|
||||
set_depth_test((eGPUDepthTest)state.depth_test);
|
||||
}
|
||||
if (changed.stencil_test != 0 || changed.stencil_op != 0) {
|
||||
set_stencil_test(state.stencil_test, state.stencil_op);
|
||||
set_stencil_mask(state.stencil_test, mutable_state);
|
||||
set_stencil_test((eGPUStencilTest)state.stencil_test, (eGPUStencilOp)state.stencil_op);
|
||||
set_stencil_mask((eGPUStencilTest)state.stencil_test, mutable_state);
|
||||
}
|
||||
if (changed.clip_distances != 0) {
|
||||
set_clip_distances(state.clip_distances, current_.clip_distances);
|
||||
}
|
||||
if (changed.culling_test != 0) {
|
||||
set_backface_culling(state.culling_test);
|
||||
set_backface_culling((eGPUFaceCullTest)state.culling_test);
|
||||
}
|
||||
if (changed.logic_op_xor != 0) {
|
||||
set_logic_op(state.logic_op_xor);
|
||||
@@ -90,7 +90,7 @@ void GLStateManager::set_state(const GPUState &state)
|
||||
set_facing(state.invert_facing);
|
||||
}
|
||||
if (changed.provoking_vert != 0) {
|
||||
set_provoking_vert(state.provoking_vert);
|
||||
set_provoking_vert((eGPUProvokingVertex)state.provoking_vert);
|
||||
}
|
||||
if (changed.shadow_bias != 0) {
|
||||
set_shadow_bias(state.shadow_bias);
|
||||
@@ -160,7 +160,7 @@ void GLStateManager::set_mutable_state(const GPUStateMutable &state)
|
||||
|
||||
if (changed.stencil_compare_mask != 0 || changed.stencil_reference != 0 ||
|
||||
changed.stencil_write_mask != 0) {
|
||||
set_stencil_mask(current_.stencil_test, state);
|
||||
set_stencil_mask((eGPUStencilTest)current_.stencil_test, state);
|
||||
}
|
||||
|
||||
current_mutable_ = state;
|
||||
|
||||
Reference in New Issue
Block a user