Browse Source

Changed `RD::PipelineDynamicStateFlags` type to enum flags

Yuri Rubinsky 2 years ago
parent
commit
6e48db69a3

+ 8 - 8
doc/classes/RenderingDevice.xml

@@ -425,7 +425,7 @@
 			<param index="5" name="multisample_state" type="RDPipelineMultisampleState" />
 			<param index="5" name="multisample_state" type="RDPipelineMultisampleState" />
 			<param index="6" name="stencil_state" type="RDPipelineDepthStencilState" />
 			<param index="6" name="stencil_state" type="RDPipelineDepthStencilState" />
 			<param index="7" name="color_blend_state" type="RDPipelineColorBlendState" />
 			<param index="7" name="color_blend_state" type="RDPipelineColorBlendState" />
-			<param index="8" name="dynamic_state_flags" type="int" default="0" />
+			<param index="8" name="dynamic_state_flags" type="int" enum="RenderingDevice.PipelineDynamicStateFlags" default="0" />
 			<param index="9" name="for_render_pass" type="int" default="0" />
 			<param index="9" name="for_render_pass" type="int" default="0" />
 			<param index="10" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" />
 			<param index="10" name="specialization_constants" type="RDPipelineSpecializationConstant[]" default="[]" />
 			<description>
 			<description>
@@ -1453,19 +1453,19 @@
 		</constant>
 		</constant>
 		<constant name="BLEND_OP_MAX" value="5" enum="BlendOperation">
 		<constant name="BLEND_OP_MAX" value="5" enum="BlendOperation">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_LINE_WIDTH" value="1" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_LINE_WIDTH" value="1" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_DEPTH_BIAS" value="2" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_DEPTH_BIAS" value="2" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_BLEND_CONSTANTS" value="4" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_BLEND_CONSTANTS" value="4" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_DEPTH_BOUNDS" value="8" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_DEPTH_BOUNDS" value="8" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_STENCIL_COMPARE_MASK" value="16" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_STENCIL_COMPARE_MASK" value="16" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_STENCIL_WRITE_MASK" value="32" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_STENCIL_WRITE_MASK" value="32" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
-		<constant name="DYNAMIC_STATE_STENCIL_REFERENCE" value="64" enum="PipelineDynamicStateFlags">
+		<constant name="DYNAMIC_STATE_STENCIL_REFERENCE" value="64" enum="PipelineDynamicStateFlags" is_bitfield="true">
 		</constant>
 		</constant>
 		<constant name="INITIAL_ACTION_CLEAR" value="0" enum="InitialAction">
 		<constant name="INITIAL_ACTION_CLEAR" value="0" enum="InitialAction">
 		</constant>
 		</constant>

+ 8 - 8
drivers/vulkan/rendering_device_vulkan.cpp

@@ -6460,7 +6460,7 @@ Vector<uint8_t> RenderingDeviceVulkan::buffer_get_data(RID p_buffer) {
 /**** RENDER PIPELINE ****/
 /**** RENDER PIPELINE ****/
 /*************************/
 /*************************/
 
 
-RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass, const Vector<PipelineSpecializationConstant> &p_specialization_constants) {
+RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, BitField<PipelineDynamicStateFlags> p_dynamic_state_flags, uint32_t p_for_render_pass, const Vector<PipelineSpecializationConstant> &p_specialization_constants) {
 	_THREAD_SAFE_METHOD_
 	_THREAD_SAFE_METHOD_
 
 
 	// Needs a shader.
 	// Needs a shader.
@@ -6746,31 +6746,31 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
 	dynamic_states.push_back(VK_DYNAMIC_STATE_VIEWPORT); // Viewport and scissor are always dynamic.
 	dynamic_states.push_back(VK_DYNAMIC_STATE_VIEWPORT); // Viewport and scissor are always dynamic.
 	dynamic_states.push_back(VK_DYNAMIC_STATE_SCISSOR);
 	dynamic_states.push_back(VK_DYNAMIC_STATE_SCISSOR);
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_LINE_WIDTH) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_LINE_WIDTH)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_LINE_WIDTH);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_LINE_WIDTH);
 	}
 	}
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_DEPTH_BIAS) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_DEPTH_BIAS)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_BIAS);
 	}
 	}
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_BLEND_CONSTANTS) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_BLEND_CONSTANTS)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
 	}
 	}
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_DEPTH_BOUNDS) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_DEPTH_BOUNDS)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_DEPTH_BOUNDS);
 	}
 	}
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_STENCIL_COMPARE_MASK)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK);
 	}
 	}
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_STENCIL_WRITE_MASK) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_STENCIL_WRITE_MASK)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_STENCIL_WRITE_MASK);
 	}
 	}
 
 
-	if (p_dynamic_state_flags & DYNAMIC_STATE_STENCIL_REFERENCE) {
+	if (p_dynamic_state_flags.has_flag(DYNAMIC_STATE_STENCIL_REFERENCE)) {
 		dynamic_states.push_back(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
 		dynamic_states.push_back(VK_DYNAMIC_STATE_STENCIL_REFERENCE);
 	}
 	}
 
 

+ 1 - 1
drivers/vulkan/rendering_device_vulkan.h

@@ -1132,7 +1132,7 @@ public:
 	/**** RENDER PIPELINE ****/
 	/**** RENDER PIPELINE ****/
 	/*************************/
 	/*************************/
 
 
-	virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>());
+	virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, BitField<PipelineDynamicStateFlags> p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>());
 	virtual bool render_pipeline_is_valid(RID p_pipeline);
 	virtual bool render_pipeline_is_valid(RID p_pipeline);
 
 
 	/**************************/
 	/**************************/

+ 8 - 8
servers/rendering/rendering_device.cpp

@@ -286,7 +286,7 @@ static Vector<RenderingDevice::PipelineSpecializationConstant> _get_spec_constan
 	return ret;
 	return ret;
 }
 }
 
 
-RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants) {
+RID RenderingDevice::_render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, BitField<PipelineDynamicStateFlags> p_dynamic_state_flags, uint32_t p_for_render_pass, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants) {
 	PipelineRasterizationState rasterization_state;
 	PipelineRasterizationState rasterization_state;
 	if (p_rasterization_state.is_valid()) {
 	if (p_rasterization_state.is_valid()) {
 		rasterization_state = p_rasterization_state->base;
 		rasterization_state = p_rasterization_state->base;
@@ -906,13 +906,13 @@ void RenderingDevice::_bind_methods() {
 	BIND_ENUM_CONSTANT(BLEND_OP_MAXIMUM);
 	BIND_ENUM_CONSTANT(BLEND_OP_MAXIMUM);
 	BIND_ENUM_CONSTANT(BLEND_OP_MAX);
 	BIND_ENUM_CONSTANT(BLEND_OP_MAX);
 
 
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_LINE_WIDTH);
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_DEPTH_BIAS);
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_BLEND_CONSTANTS);
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_DEPTH_BOUNDS);
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_STENCIL_COMPARE_MASK);
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_STENCIL_WRITE_MASK);
-	BIND_ENUM_CONSTANT(DYNAMIC_STATE_STENCIL_REFERENCE);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_LINE_WIDTH);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_DEPTH_BIAS);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_BLEND_CONSTANTS);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_DEPTH_BOUNDS);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_STENCIL_COMPARE_MASK);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_STENCIL_WRITE_MASK);
+	BIND_BITFIELD_FLAG(DYNAMIC_STATE_STENCIL_REFERENCE);
 
 
 	BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR); //start rendering and clear the framebuffer (supply params)
 	BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR); //start rendering and clear the framebuffer (supply params)
 	BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR_REGION); //start rendering and clear the framebuffer (supply params)
 	BIND_ENUM_CONSTANT(INITIAL_ACTION_CLEAR_REGION); //start rendering and clear the framebuffer (supply params)

+ 3 - 3
servers/rendering/rendering_device.h

@@ -1112,7 +1112,7 @@ public:
 	};
 	};
 
 
 	virtual bool render_pipeline_is_valid(RID p_pipeline) = 0;
 	virtual bool render_pipeline_is_valid(RID p_pipeline) = 0;
-	virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>()) = 0;
+	virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, BitField<PipelineDynamicStateFlags> p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>()) = 0;
 
 
 	/**************************/
 	/**************************/
 	/**** COMPUTE PIPELINE ****/
 	/**** COMPUTE PIPELINE ****/
@@ -1322,7 +1322,7 @@ protected:
 
 
 	Error _buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS);
 	Error _buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, BitField<BarrierMask> p_post_barrier = BARRIER_MASK_ALL_BARRIERS);
 
 
-	RID _render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants);
+	RID _render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, BitField<PipelineDynamicStateFlags> p_dynamic_state_flags, uint32_t p_for_render_pass, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants);
 	RID _compute_pipeline_create(RID p_shader, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants);
 	RID _compute_pipeline_create(RID p_shader, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants);
 
 
 	Vector<int64_t> _draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2(), const TypedArray<RID> &p_storage_textures = TypedArray<RID>());
 	Vector<int64_t> _draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2(), const TypedArray<RID> &p_storage_textures = TypedArray<RID>());
@@ -1357,7 +1357,7 @@ VARIANT_ENUM_CAST(RenderingDevice::StencilOperation)
 VARIANT_ENUM_CAST(RenderingDevice::LogicOperation)
 VARIANT_ENUM_CAST(RenderingDevice::LogicOperation)
 VARIANT_ENUM_CAST(RenderingDevice::BlendFactor)
 VARIANT_ENUM_CAST(RenderingDevice::BlendFactor)
 VARIANT_ENUM_CAST(RenderingDevice::BlendOperation)
 VARIANT_ENUM_CAST(RenderingDevice::BlendOperation)
-VARIANT_ENUM_CAST(RenderingDevice::PipelineDynamicStateFlags)
+VARIANT_BITFIELD_CAST(RenderingDevice::PipelineDynamicStateFlags)
 VARIANT_ENUM_CAST(RenderingDevice::PipelineSpecializationConstantType)
 VARIANT_ENUM_CAST(RenderingDevice::PipelineSpecializationConstantType)
 VARIANT_ENUM_CAST(RenderingDevice::InitialAction)
 VARIANT_ENUM_CAST(RenderingDevice::InitialAction)
 VARIANT_ENUM_CAST(RenderingDevice::FinalAction)
 VARIANT_ENUM_CAST(RenderingDevice::FinalAction)