Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use specialization constants in clustered renderer #50402

Merged
merged 1 commit into from
Jul 13, 2021

Conversation

reduz
Copy link
Member

@reduz reduz commented Jul 12, 2021

  • Keep track of when projector, soft shadows or directional soft shadows are enabled.
  • Enable them via specialization constant where it makes sense.
  • Re-implements soft shadows.
  • Re-implements light projectors.

image

Bugsquad edit: Follow-up to #50325. This closes #45733 and closes #50094.

* Keep track of when projector, softshadow or directional sofshadow were enabled.
* Enable them via specializaton constant where it makes sense.
* Re-implements soft shadows.
* Re-implements light projectors.
@reduz reduz requested a review from a team as a code owner July 12, 2021 23:42
@Calinou Calinou added this to the 4.0 milestone Jul 12, 2021
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -6047,7 +6045,7 @@ RID RenderingDeviceVulkan::render_pipeline_create(RID p_shader, FramebufferForma
const PipelineSpecializationConstant &psc = p_specialization_constants[j];
if (psc.constant_id == sc.constant.constant_id) {
ERR_FAIL_COND_V_MSG(psc.type != sc.constant.type, RID(), "Specialization constant provided for id (" + itos(sc.constant.constant_id) + ") is of the wrong type.");
data_ptr[i] = sc.constant.int_value;
data_ptr[i] = psc.int_value;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took the chance to fix this bug


pipeline_stages.write[k].pSpecializationInfo = specialization_info.ptr();
pipeline_stages.write[i].pSpecializationInfo = specialization_info.ptr() + i;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also a bugfix

@@ -318,11 +318,11 @@ void RenderForwardClustered::_render_list_template(RenderingDevice::DrawListID p
RID prev_pipeline_rd;
RID prev_xforms_uniform_set;

bool shadow_pass = (p_params->pass_mode == PASS_MODE_SHADOW) || (p_params->pass_mode == PASS_MODE_SHADOW_DP);
bool shadow_pass = (p_pass_mode == PASS_MODE_SHADOW) || (p_pass_mode == PASS_MODE_SHADOW_DP);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be using p_pass_mode which is resolved at compile time for more performance., so replaced it.

@BastiaanOlij
Copy link
Contributor

Need to look at this more closely but sounds like a good way to improve multiview as well, instead of using defines add a constant in. Though not sure if that would rhyme well with us not wanting to compile any multiview shaders if XR is not enabled.

@reduz
Copy link
Member Author

reduz commented Jul 13, 2021

@BastiaanOlij specialization constants work as long as you dont add any new input or output to the shaders, not sure if this is the case with multiview, but probably not.

@reduz reduz merged commit e2a2138 into godotengine:master Jul 13, 2021
@BastiaanOlij
Copy link
Contributor

@BastiaanOlij specialization constants work as long as you dont add any new input or output to the shaders, not sure if this is the case with multiview, but probably not.

Hmmm, thats a good point because Multiview adds the gl_ViewIndex built-in input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants