Skip to content

Commit

Permalink
Feat/cleanup unused image logic (#54)
Browse files Browse the repository at this point in the history
* feat: cleanup image material sampler

Signed-off-by: Michael Pollind <[email protected]>

* bugfix: resolve image sampler artifacts and start cleanup

Signed-off-by: Michael Pollind <[email protected]>

* feat: remove occlusion query logic

Signed-off-by: Michael Pollind <[email protected]>

---------

Signed-off-by: Michael Pollind <[email protected]>
  • Loading branch information
pollend authored Aug 25, 2023
1 parent 318e459 commit 7ee68c0
Show file tree
Hide file tree
Showing 42 changed files with 499 additions and 730 deletions.
289 changes: 194 additions & 95 deletions HPL2/include/graphics/ForgeHandles.h

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions HPL2/include/graphics/ForgeRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ namespace hpl {
*/
class CommandResourcePool {
public:
using VariantTypes = std::variant<ForgeSwapChainHandle,
ForgeTextureHandle,
ForgeBufferHandle,
ForgeRenderTarget>;
using VariantTypes = std::variant<SharedSwapChain,
SharedTexture,
SharedBuffer,
SharedRenderTarget>;
// could be done better ...
CommandResourcePool() = default;

Expand Down Expand Up @@ -161,7 +161,7 @@ namespace hpl {
std::array<Semaphore*, SwapChainLength> m_renderCompleteSemaphores;
std::array<CmdPool*, SwapChainLength> m_cmdPools;
std::array<Cmd*, SwapChainLength> m_cmds;
std::array<ForgeRenderTarget, SwapChainLength> m_finalRenderTarget;
std::array<SharedRenderTarget, SwapChainLength> m_finalRenderTarget;

float m_gamma = 1.0f;

Expand All @@ -170,20 +170,20 @@ namespace hpl {

Renderer* m_renderer = nullptr;
RootSignature* m_pipelineSignature = nullptr;
ForgeSwapChainHandle m_swapChain;
SharedSwapChain m_swapChain;
Semaphore* m_imageAcquiredSemaphore = nullptr;
Queue* m_graphicsQueue = nullptr;

Shader* m_copyShader = nullptr;
Pipeline* m_copyPostProcessingPipelineToSwapChain = nullptr;
Pipeline* m_copyPostProcessingPipelineToUnormR8G8B8A8 = nullptr;

ForgePipelineHandle m_finalPipeline;
ForgeShaderHandle m_finalShader;
SharedPipeline m_finalPipeline;
SharedShader m_finalShader;
RootSignature* m_finalRootSignature = nullptr;
std::array<ForgeDescriptorSet, SwapChainLength> m_finalPerFrameDescriptorSet;
std::array<SharedDescriptorSet, SwapChainLength> m_finalPerFrameDescriptorSet;

ForgeSamplerHandle m_pointSampler ;
SharedSampler m_pointSampler ;

RootSignature* m_copyPostProcessingRootSignature = nullptr;
DescriptorSet* m_copyPostProcessingDescriptorSet = nullptr;
Expand Down
13 changes: 0 additions & 13 deletions HPL2/include/graphics/GraphicsTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -812,19 +812,6 @@ namespace hpl {
class iOcclusionQuery;
class iVertexBuffer;

class cOcclusionQueryObject
{
public:
cOcclusionQueryObject() : mpQuery(NULL), mpVtxBuffer(NULL),mpMatrix(NULL), mbDepthTest(false), mlSampleResults(0) {}

int mlCustomID;
iOcclusionQuery *mpQuery;
iVertexBuffer *mpVtxBuffer;
cMatrixf *mpMatrix;
bool mbDepthTest;
int mlSampleResults;
};

//---------------------------------------
class iTexture;
class iDepthStencilBuffer;
Expand Down
12 changes: 3 additions & 9 deletions HPL2/include/graphics/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace hpl {
Image& operator=(const Image& other) = delete;
void operator=(Image&& other);

inline void SetForgeTexture(ForgeTextureHandle&& handle) {
inline void SetForgeTexture(SharedTexture&& handle) {
m_texture = std::move(handle);
}

Expand All @@ -74,16 +74,10 @@ namespace hpl {
return cVector2l(0, 0);
}

inline ForgeTextureHandle& GetTexture() {
inline SharedTexture& GetTexture() {
return m_texture;
}
inline eTextureWrap textureWrapMode() { return m_textureWrapMode; }
void setTextureFilter(const eTextureFilter& filter);
void setWrapMode(const eTextureWrap& wrap);

SamplerDesc m_samplerDesc{};
ForgeTextureHandle m_texture;
eTextureWrap m_textureWrapMode;
SharedTexture m_texture;
};

} // namespace hpl
57 changes: 28 additions & 29 deletions HPL2/include/graphics/LowLevelGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
namespace hpl {

class iFontData;
class iOcclusionQuery;
class iGpuShader;
class iTexture;
class iVertexBuffer;
Expand Down Expand Up @@ -130,7 +129,7 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual iFrameBuffer* CreateFrameBuffer(const tString& asName)=0;

[[deprecated("interface is deprecated")]]
virtual iDepthStencilBuffer* CreateDepthStencilBuffer(const cVector2l& avSize, int alDepthBits, int alStencilBits)=0;

Expand All @@ -139,10 +138,10 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual void SetClearColor(const cColor& aCol)=0;

[[deprecated("interface is deprecated")]]
virtual void SetClearDepth(float afDepth)=0;

[[deprecated("interface is deprecated")]]
virtual void SetClearStencil(int alVal)=0;

Expand Down Expand Up @@ -192,10 +191,10 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual iFrameBuffer* GetCurrentFrameBuffer()=0;

[[deprecated("interface is deprecated")]]
virtual void SetColorWriteActive(bool abR,bool abG,bool abB,bool abA)=0;

[[deprecated("interface is deprecated")]]
virtual void SetDepthWriteActive(bool abX)=0;

Expand Down Expand Up @@ -225,11 +224,11 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual void SetStencilWriteMask(unsigned int alMask)=0;

[[deprecated("interface is deprecated")]]
virtual void SetStencil(eStencilFunc aFunc,int alRef, unsigned int aMask,
eStencilOp aFailOp,eStencilOp aZFailOp,eStencilOp aZPassOp)=0;

[[deprecated("interface is deprecated")]]
virtual void SetStencilTwoSide(eStencilFunc aFrontFunc,eStencilFunc aBackFunc,
int alRef, unsigned int aMask,
Expand Down Expand Up @@ -287,7 +286,7 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual void SetOrthoProjection(const cVector2f& avSize, float afMin, float afMax)=0;

[[deprecated("interface is deprecated")]]
virtual void SetOrthoProjection(const cVector3f& avMin, const cVector3f& avMax)=0;

Expand All @@ -308,13 +307,13 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual void DrawQuad( const cVector3f &avPos,const cVector2f &avSize, const cColor& aColor=cColor(1,1))=0;


[[deprecated("interface is deprecated")]]
virtual void DrawQuad( const cVector3f &avPos,const cVector2f &avSize,
const cVector2f &avMinTexCoord,const cVector2f &avMaxTexCoord,
const cColor& aColor=cColor(1,1))=0;

[[deprecated("interface is deprecated")]]
virtual void DrawQuad( const cVector3f &avPos,const cVector2f &avSize,
const cVector2f &avMinTexCoord0,const cVector2f &avMaxTexCoord0,
Expand All @@ -326,33 +325,33 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual void DrawQuad(const tVertexVec &avVtx, const cColor aCol)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawQuad(const tVertexVec &avVtx,const float afZ)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawQuad(const tVertexVec &avVtx,const float afZ,const cColor &aCol)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawQuadMultiTex(const tVertexVec &avVtx,const tVector3fVec &avExtraUvs)=0;


[[deprecated("interface is deprecated")]]
virtual void DrawLine(const cVector3f& avBegin, const cVector3f& avEnd, cColor aCol)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawLine(const cVector3f& avBegin, const cColor& aBeginCol, const cVector3f& avEnd, const cColor& aEndCol)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawBoxMinMax(const cVector3f& avMin, const cVector3f& avMax, cColor aCol)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawSphere(const cVector3f& avPos, float afRadius, cColor aCol)=0;

[[deprecated("interface is deprecated")]]
virtual void DrawSphere(const cVector3f& avPos, float afRadius, cColor aColX, cColor aColY, cColor aColZ)=0;


[[deprecated("interface is deprecated")]]
virtual void DrawLineQuad(const cRect2f& aRect, float afZ, cColor aCol)=0;
[[deprecated("interface is deprecated")]]
Expand All @@ -362,17 +361,17 @@ namespace hpl {
/////////// VERTEX BATCHING /////////////////////////
/////////////////////////////////////////////////////


[[deprecated("interface is deprecated")]]
virtual void AddVertexToBatch(const cVertex *apVtx)=0;

[[deprecated("interface is deprecated")]]
virtual void AddVertexToBatch(const cVertex *apVtx, const cVector3f* avTransform)=0;

[[deprecated("interface is deprecated")]]
virtual void AddVertexToBatch(const cVertex *apVtx, const cMatrixf* aMtx)=0;


[[deprecated("interface is deprecated")]]
virtual void AddVertexToBatch_Size2D(const cVertex *apVtx, const cVector3f* avTransform,
const cColor* apCol,const float& mfW, const float& mfH)=0;
Expand All @@ -387,16 +386,16 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
virtual void AddTexCoordToBatch(unsigned int alUnit,const cVector3f *apCoord)=0;

[[deprecated("interface is deprecated")]]
virtual void SetBatchTextureUnitActive(unsigned int alUnit,bool abActive)=0;

[[deprecated("interface is deprecated")]]
virtual void FlushTriBatch(tVtxBatchFlag aTypeFlags, bool abAutoClear=true)=0;

[[deprecated("interface is deprecated")]]
virtual void FlushQuadBatch(tVtxBatchFlag aTypeFlags, bool abAutoClear=true)=0;

[[deprecated("interface is deprecated")]]
virtual void ClearBatch()=0;

Expand All @@ -406,7 +405,7 @@ namespace hpl {

[[deprecated("interface is deprecated")]]
static void SetForceShaderModel3And4Off(bool abX){ mbForceShaderModel3And4Off = abX;}

[[deprecated("interface is deprecated")]]
static bool GetForceShaderModel3And4Off(){ return mbForceShaderModel3And4Off;}

Expand Down
15 changes: 9 additions & 6 deletions HPL2/include/graphics/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ namespace hpl {
};


class cMaterial : public iResourceBase
{
class cMaterial : public iResourceBase {
friend class iMaterialType;
public:
static constexpr uint32_t MaxMaterialID = 2048;
Expand Down Expand Up @@ -276,8 +275,14 @@ namespace hpl {
inline TextureAntistropy GetTextureAntistropy() const { return m_antistropy; }
inline eTextureWrap GetTextureWrap() const { return m_textureWrap; }

inline void setTextureFilter(eTextureFilter filter) { m_textureFilter = filter; }
inline void setTextureWrap(eTextureWrap wrap) { m_textureWrap = wrap; }
inline void setTextureFilter(eTextureFilter filter) {
m_textureFilter = filter;
Dirty();
}
inline void setTextureWrap(eTextureWrap wrap) {
m_textureWrap = wrap;
Dirty();
}
inline int GetRenderFrameCount() const { return mlRenderFrameCount;}
inline void SetRenderFrameCount(const int alCount) { mlRenderFrameCount = alCount;}

Expand All @@ -302,14 +307,12 @@ namespace hpl {
static void SetDestroyTypeSpecifics(bool abX){ mbDestroyTypeSpecifics = abX; }
static bool GetDestroyTypeSpecifics(){ return mbDestroyTypeSpecifics; }

//resources stuff.
bool Reload(){ return false;}
void Unload(){}
void Destroy(){}

inline MaterialType& type() { return m_info; }

// inline ForgeBufferHandle& uniformHandle() { return m_bufferHandle; }
inline uint32_t materialID() { return m_info.m_handle.get(); }
inline uint32_t Version() { return m_version; }
inline void Dirty() { m_version++; }
Expand Down
4 changes: 2 additions & 2 deletions HPL2/include/graphics/MaterialType_BasicSolid.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace hpl {

class cMaterialType_SolidDiffuse_Vars : public iMaterialVars {
public:
std::array<ForgeBufferHandle, ForgeRenderer::SwapChainLength> m_buffer;
std::array<SharedBuffer, ForgeRenderer::SwapChainLength> m_buffer;

cMaterialType_SolidDiffuse_Vars()
: mfHeightMapScale(0.05f)
Expand Down Expand Up @@ -111,7 +111,7 @@ namespace hpl {
void LoadVariables(cMaterial* apMaterial, cResourceVarsObject* apVars) override;
void GetVariableValues(cMaterial* apMaterial, cResourceVarsObject* apVars) override;

std::array<ForgeDescriptorSet, eMaterialTexture_LastEnum> m_descriptorSet;
std::array<SharedDescriptorSet, eMaterialTexture_LastEnum> m_descriptorSet;
private:
uint32_t m_materialCount = 0;
void CompileSolidSpecifics(cMaterial* apMaterial) override;
Expand Down
23 changes: 12 additions & 11 deletions HPL2/include/graphics/PassHBAOPlus.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ class PassHBAOPlus final {
}

// 16 depth intermediary buffers
ForgeTextureHandle m_preparedDepth = {};
ForgeTextureHandle m_aoQurter = {};
ForgeDescriptorSet m_constDescriptorSet = {};
SharedTexture m_preparedDepth = {};
SharedTexture m_aoQurter = {};
SharedDescriptorSet m_constDescriptorSet = {};
uint2 m_size = uint2(0, 0);
cFrustum* m_frustum = nullptr;
std::array<ForgeDescriptorSet, ForgeRenderer::SwapChainLength> m_perFrameDescriptorSet = {};
ForgeBufferHandle m_constBuffer;
std::array<SharedDescriptorSet, ForgeRenderer::SwapChainLength> m_perFrameDescriptorSet = {};
SharedBuffer m_constBuffer;
};

struct HBAORootConstant {
Expand All @@ -96,6 +96,7 @@ class PassHBAOPlus final {
float foregroundViewDepth;
float pad[2];
};

PassHBAOPlus();
void cmdDraw(
const ForgeRenderer::Frame& frame,
Expand All @@ -109,14 +110,14 @@ class PassHBAOPlus final {
UniqueViewportData<ViewportData> m_boundViewportData;
RootSignature* m_rootSignature;

ForgeShaderHandle m_shaderDeinterleave;
ForgePipelineHandle m_pipelineDeinterleave;
SharedShader m_shaderDeinterleave;
SharedPipeline m_pipelineDeinterleave;

ForgeShaderHandle m_shaderCourseAO;
ForgePipelineHandle m_pipelineCourseAO;
SharedShader m_shaderCourseAO;
SharedPipeline m_pipelineCourseAO;

ForgeShaderHandle m_shaderReinterleave;
ForgePipelineHandle m_pipelineReinterleave;
SharedShader m_shaderReinterleave;
SharedPipeline m_pipelineReinterleave;

Sampler* m_pointSampler;
};
Expand Down
2 changes: 1 addition & 1 deletion HPL2/include/graphics/PostEffectComposite.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ namespace hpl {
cVector2l m_size = cVector2l(0, 0);
uint32_t m_pogoTargetIndex = 1;
// 2 render targets two ping pong between
std::array<ForgeRenderTarget, 2> m_renderTarget;
std::array<SharedRenderTarget, 2> m_renderTarget;
};


Expand Down
Loading

0 comments on commit 7ee68c0

Please sign in to comment.