Skip to content

Commit

Permalink
style: ref renderer cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan hoffstadt committed Apr 24, 2024
1 parent daa4f0b commit a105c3d
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions extensions/pl_ref_renderer_ext.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,33 +57,26 @@ typedef struct _plComputeShaderVariant
const void* pTempConstantData;
} plComputeShaderVariant;

typedef struct _plOBB
{
plVec3 tCenter;
plVec3 tExtents;
plVec3 atAxes[3]; // Orthonormal basis
} plOBB;

typedef struct _plSkinData
{
plEntity tEntity;
plTextureHandle atDynamicTexture[PL_FRAMES_IN_FLIGHT];
plBindGroupHandle tTempBindGroup;
plEntity tEntity;
plTextureHandle atDynamicTexture[PL_FRAMES_IN_FLIGHT];
plBindGroupHandle tTempBindGroup;
} plSkinData;

typedef struct _plDrawable
{
plEntity tEntity;
plEntity tEntity;
plBindGroupHandle tMaterialBindGroup;
uint32_t uDataOffset;
uint32_t uVertexOffset;
uint32_t uVertexCount;
uint32_t uIndexOffset;
uint32_t uIndexCount;
uint32_t uMaterialIndex;
uint32_t uShader;
uint32_t uSkinIndex;
bool bCulled;
uint32_t uDataOffset;
uint32_t uVertexOffset;
uint32_t uVertexCount;
uint32_t uIndexOffset;
uint32_t uIndexCount;
uint32_t uMaterialIndex;
uint32_t uShader;
uint32_t uSkinIndex;
bool bCulled;
} plDrawable;

typedef struct _plMaterial
Expand Down Expand Up @@ -139,20 +132,20 @@ typedef struct _plRefScene
plRenderPassLayoutHandle tRenderPassLayout;

// shader templates
plShaderHandle tOpaqueShader;
plShaderHandle tTransparentShader;
uint32_t uVariantCount;
const plShaderVariant* ptVariants;
plHashMap tVariantHashmap;
plShaderHandle* _sbtVariantHandles; // needed for cleanup
plShaderHandle tOpaqueShader;
plShaderHandle tTransparentShader;
uint32_t uVariantCount;
const plShaderVariant* ptVariants;
plHashMap tVariantHashmap;
plShaderHandle* _sbtVariantHandles; // needed for cleanup

// lighting
plDrawable tLightingDrawable;

// skybox
plDrawable tSkyboxDrawable;
plTextureHandle tSkyboxTexture;
plBindGroupHandle tSkyboxBindGroup;
plDrawable tSkyboxDrawable;
plTextureHandle tSkyboxTexture;
plBindGroupHandle tSkyboxBindGroup;

// CPU buffers
plVec3* sbtVertexPosBuffer;
Expand All @@ -166,8 +159,9 @@ typedef struct _plRefScene
plBufferHandle tStorageBuffer;
plBufferHandle tMaterialDataBuffer;

uint32_t uViewCount;
plRefView atViews[PL_MAX_VIEWS_PER_SCENE];
// views
uint32_t uViewCount;
plRefView atViews[PL_MAX_VIEWS_PER_SCENE];
plSkinData* sbtSkinData;

plComponentLibrary tComponentLibrary;
Expand Down Expand Up @@ -2327,6 +2321,14 @@ pl__sat_visibility_test(plCameraComponent* ptCamera, const plAABB* ptAABB)
atCorners[i] = pl_mul_mat4_vec3(&ptCamera->tViewMat, atCorners[i]);

// Use transformed atCorners to calculate center, axes and extents

typedef struct _plOBB
{
plVec3 tCenter;
plVec3 tExtents;
plVec3 atAxes[3]; // Orthonormal basis
} plOBB;

plOBB tObb = {
.atAxes = {
pl_sub_vec3(atCorners[1], atCorners[0]),
Expand Down

0 comments on commit a105c3d

Please sign in to comment.