Skip to content

Commit

Permalink
works only for supported shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
MCRcortex committed Oct 12, 2023
1 parent da20764 commit 06e56fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ private record RtPipeline(VRaytracePipeline pipeline, int commonSet, int geomSet

private final int maxIrisRenderTargets = 16;

private final boolean supportsEntities;

public VulkanPipeline(VContext ctx, AccelerationManager accelerationManager, RaytracingShaderSet[] passes, int[] ssboIds, VGImage[] customTextures) {
this.ctx = ctx;
this.accelerationManager = accelerationManager;
Expand Down Expand Up @@ -155,9 +157,18 @@ public VulkanPipeline(VContext ctx, AccelerationManager accelerationManager, Ray
.maxAnisotropy(1.0f));

if (passes == null) {
supportsEntities = false;
return;
}

boolean supportsEntitiesT = true;
for (var pass : passes) {
if (pass.getRayHitCount() == 1) {
supportsEntitiesT = false;
break;
}
}
supportsEntities = supportsEntitiesT;
try {
var commonSetExpected = new ShaderReflection.Set(new ShaderReflection.Binding[]{
new ShaderReflection.Binding("", 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 0, false),
Expand Down Expand Up @@ -227,7 +238,7 @@ public VulkanPipeline(VContext ctx, AccelerationManager accelerationManager, Ray

private final EntityCapture capture = new EntityCapture();
private void buildEntities() {
accelerationManager.setEntityData(capture.capture(CapturedRenderingState.INSTANCE.getTickDelta(), MinecraftClient.getInstance().world));
accelerationManager.setEntityData(supportsEntities?capture.capture(CapturedRenderingState.INSTANCE.getTickDelta(), MinecraftClient.getInstance().world):null);
}

public void renderPostShadows(List<VGImage> outImgs, Camera camera, ShaderStorageBuffer[] ssbos, MixinCelestialUniforms celestialUniforms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public void apply(RaytracePipelineBuilder builder) {
}
}

public int getRayHitCount() {
return rayhits.length;
}

public void delete() {
for (var shader : allShader) {
shader.free();
Expand Down

0 comments on commit 06e56fb

Please sign in to comment.