Skip to content

Commit

Permalink
WIP cube
Browse files Browse the repository at this point in the history
WIP cube 2

WIP
  • Loading branch information
hoffstadt committed Jan 21, 2025
1 parent c1c2b84 commit ad7b705
Show file tree
Hide file tree
Showing 14 changed files with 290 additions and 277 deletions.
2 changes: 2 additions & 0 deletions extensions/pl_ecs_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ pl_ecs_add_component(plComponentLibrary* ptLibrary, plComponentType tType, plEnt
sbComponents[uComponentIndex] = (plEnvironmentProbeComponent){
.fRange = 10.0f,
.uResolution = 128,
.uSamples = 128,
.uInterval = 1,
.tFlags = PL_ENVIRONMENT_PROBE_FLAGS_DIRTY
};
return &sbComponents[uComponentIndex];
Expand Down
2 changes: 2 additions & 0 deletions extensions/pl_ecs_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ typedef struct _plEnvironmentProbeComponent
{
plEnvironmentProbeFlags tFlags;
uint32_t uResolution; // default: 128 (must be power of two)
uint32_t uSamples; // default: 128
uint32_t uInterval; // default: 1 (1 to 6 for realtime probe)
plVec3 tPosition;
float fRange;
} plEnvironmentProbeComponent;
Expand Down
7 changes: 6 additions & 1 deletion extensions/pl_graphics_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ pl__cleanup_common_device(plDevice* ptDevice)
pl_sb_free(ptDevice->sbtBufferFreeIndices);
pl_sb_free(ptDevice->sbtTexturesCold);
pl_sb_free(ptDevice->sbtSamplersCold);
pl_sb_free(ptDevice->sbtBindGroupsCold);
pl_sb_free(ptDevice->sbtRenderPassesCold);
pl_sb_free(ptDevice->sbtTextureFreeIndices);
pl_sb_free(ptDevice->sbtRenderPassLayoutsCold);
Expand All @@ -357,6 +356,12 @@ pl__cleanup_common_device(plDevice* ptDevice)
pl_sb_free(ptDevice->sbtRenderPassLayoutFreeIndices);
pl_sb_free(ptDevice->sbtRenderPassFreeIndices);

for(uint32_t i = 0; i < pl_sb_size(ptDevice->sbtBindGroupsCold); i++)
{
pl_sb_free(ptDevice->sbtBindGroupsCold[i]._sbtTextures);
}
pl_sb_free(ptDevice->sbtBindGroupsCold);

plTimelineSemaphore* ptCurrentSemaphore = ptDevice->ptSemaphoreFreeList;
while(ptCurrentSemaphore)
{
Expand Down
1 change: 1 addition & 0 deletions extensions/pl_graphics_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ typedef struct _plTextureViewDesc
uint32_t uBaseLayer;
uint32_t uLayerCount;
plTextureHandle tTexture;
plTextureType tType;
const char* pcDebugName; // default: "unnamed texture view"
} plTextureViewDesc;

Expand Down
6 changes: 5 additions & 1 deletion extensions/pl_graphics_metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,7 @@
ptNewTexture->tView = *ptViewDesc;
ptNewTexture->tDesc.uMips = ptViewDesc->uMips;
ptNewTexture->tDesc.uLayers = ptViewDesc->uLayerCount;
ptNewTexture->tDesc.tType = ptViewDesc->tType;
ptNewTexture->tView.uBaseMip = 0;
ptNewTexture->tView.uBaseLayer = 0;

Expand Down Expand Up @@ -1105,7 +1106,9 @@
levels:tLevelRange
slices:tSliceRange];

ptNewMetalTexture->tTexture.label = [NSString stringWithUTF8String:ptViewDesc->pcDebugName];
if(ptNewTexture->tView.pcDebugName == NULL)
ptNewTexture->tView.pcDebugName = "unnamed texture";
ptNewMetalTexture->tTexture.label = [NSString stringWithUTF8String:ptNewTexture->tView.pcDebugName];
ptNewMetalTexture->uHeap = ptOldMetalTexture->uHeap;
return tHandle;
}
Expand Down Expand Up @@ -2689,6 +2692,7 @@
pl_sb_free(ptDevice->sbtRenderPassesHot[i].atRenderPassDescriptors[j].sbptRenderPassDescriptor);
}
}
pl_sb_free(ptDevice->sbuFreeHeaps);
pl_sb_free(ptDevice->sbtTexturesHot);
pl_sb_free(ptDevice->sbtSamplersHot);
pl_sb_free(ptDevice->sbtBindGroupsHot);
Expand Down
9 changes: 5 additions & 4 deletions extensions/pl_graphics_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1265,18 +1265,19 @@ pl_create_texture_view(plDevice* ptDevice, const plTextureViewDesc* ptViewDesc)
plTexture* ptOriginalTexture = pl__get_texture(ptDevice, ptViewDesc->tTexture);
plTexture* ptNewTexture = pl__get_texture(ptDevice, ptViewDesc->tTexture);
ptNewTexture->tDesc = ptOriginalTexture->tDesc;
ptNewTexture->tDesc.tType = ptViewDesc->tType;
ptNewTexture->tView = *ptViewDesc;
plVulkanTexture* ptOldVulkanTexture = &ptDevice->sbtTexturesHot[ptViewDesc->tTexture.uIndex];
plVulkanTexture* ptNewVulkanTexture = &ptDevice->sbtTexturesHot[tHandle.uIndex];

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~create view~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

VkImageViewType tImageViewType = 0;
if (ptOriginalTexture->tDesc.tType == PL_TEXTURE_TYPE_CUBE)
if (ptNewTexture->tDesc.tType == PL_TEXTURE_TYPE_CUBE)
tImageViewType = VK_IMAGE_VIEW_TYPE_CUBE;
else if (ptOriginalTexture->tDesc.tType == PL_TEXTURE_TYPE_2D)
else if (ptNewTexture->tDesc.tType == PL_TEXTURE_TYPE_2D)
tImageViewType = VK_IMAGE_VIEW_TYPE_2D;
else if (ptOriginalTexture->tDesc.tType == PL_TEXTURE_TYPE_2D_ARRAY)
else if (ptNewTexture->tDesc.tType == PL_TEXTURE_TYPE_2D_ARRAY)
tImageViewType = VK_IMAGE_VIEW_TYPE_2D; // VK_IMAGE_VIEW_TYPE_2D_ARRAY;
else
{
Expand Down Expand Up @@ -4329,7 +4330,7 @@ pl__fill_common_render_pass_data(plRenderPassLayoutDesc* ptDesc, plRenderPassLay
.dstStageMask = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT | VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT,
.dependencyFlags = 0
.dependencyFlags = VK_DEPENDENCY_BY_REGION_BIT
};

ptDataOut->atSubpassDependencies[1] = (VkSubpassDependency){
Expand Down
8 changes: 4 additions & 4 deletions extensions/pl_renderer_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ pl_refr_reload_scene_shaders(uint32_t uSceneHandle)

pl_refr_create_global_shaders();

int iSceneWideRenderingFlags = 0;
int iSceneWideRenderingFlags = PL_RENDERING_FLAG_SHADOWS;
if(gptData->bPunctualLighting)
iSceneWideRenderingFlags |= PL_RENDERING_FLAG_USE_PUNCTUAL;
if(gptData->bImageBasedLighting)
Expand Down Expand Up @@ -1998,7 +1998,7 @@ pl_refr_reload_scene_shaders(uint32_t uSceneHandle)
tLightingShaderDesc.atConstants[i].tType = PL_DATA_TYPE_INT;
}
ptScene->tLightingShader = gptGfx->create_shader(gptData->ptDevice, &tLightingShaderDesc);
aiLightingConstantData[0] = gptData->bPunctualLighting ? PL_RENDERING_FLAG_USE_PUNCTUAL : 0;
aiLightingConstantData[0] = gptData->bPunctualLighting ? (PL_RENDERING_FLAG_USE_PUNCTUAL | PL_RENDERING_FLAG_SHADOWS) : 0;
ptScene->tEnvLightingShader = gptGfx->create_shader(gptData->ptDevice, &tLightingShaderDesc);
}

Expand Down Expand Up @@ -2201,7 +2201,7 @@ pl_refr_finalize_scene(uint32_t uSceneHandle)
gptGfx->update_bind_group(gptData->ptDevice, ptScene->tSkinBindGroup0, &tBGData0);
}

int iSceneWideRenderingFlags = 0;
int iSceneWideRenderingFlags = PL_RENDERING_FLAG_SHADOWS;
if(gptData->bPunctualLighting)
iSceneWideRenderingFlags |= PL_RENDERING_FLAG_USE_PUNCTUAL;
if(gptData->bImageBasedLighting)
Expand Down Expand Up @@ -2293,7 +2293,7 @@ pl_refr_finalize_scene(uint32_t uSceneHandle)
tLightingShaderDesc.atConstants[i].tType = PL_DATA_TYPE_INT;
}
ptScene->tLightingShader = gptGfx->create_shader(gptData->ptDevice, &tLightingShaderDesc);
aiLightingConstantData[0] = gptData->bPunctualLighting ? PL_RENDERING_FLAG_USE_PUNCTUAL : 0;
aiLightingConstantData[0] = gptData->bPunctualLighting ? (PL_RENDERING_FLAG_USE_PUNCTUAL | PL_RENDERING_FLAG_SHADOWS) : 0;
ptScene->tEnvLightingShader = gptGfx->create_shader(gptData->ptDevice, &tLightingShaderDesc);
}

Expand Down
Loading

0 comments on commit ad7b705

Please sign in to comment.