DKGL2 sample codes

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <DK.h>
  3. // simple wrapper of dk mesh
  4. class StaticMesh
  5. {
  6. public:
  7. StaticMesh();
  8. bool LoadMeshResourceFromFile(DKObject<DKGraphicsDevice> inDevice
  9. , DKResourcePool& inDKResourcePool, const DKString& inFileName);
  10. bool LoadShaderFromFile(DKResourcePool& inDKResourcePool
  11. , const DKString& inFileName
  12. , DKShaderStage inStage);
  13. // Should be seperated
  14. bool LoadTextureFromFile(DKResourcePool& inDKResourcePool
  15. , const DKString& inFileName);
  16. bool LoadRenderResourceTexture(DKObject<DKCommandQueue> queue);
  17. bool LoadRenderResourceShader(DKObject<DKGraphicsDevice> inDevice,
  18. DKShaderStage inStage);
  19. DKObject<DKMesh> Mesh() { return mesh; }
  20. void SetupPipelineDecriptor(DKRenderPipelineDescriptor& pipelineDescriptor);
  21. void SetupMaterial(DKObject<DKGraphicsDevice> inDevice);
  22. void SetupExternalUniformBuffer(DKObject<DKGpuBuffer> uniformBuffer
  23. , size_t uniformBufferSize, int index);
  24. bool EncodeRenderCommand(DKRenderCommandEncoder* encoder) const;
  25. private:
  26. DKString fileName;
  27. DKObject<DKMesh> mesh;
  28. // Temporary variables before material work
  29. DKObject<DKImage> textureSrc;
  30. DKObject<DKTexture> texture;
  31. DKObject<DKSamplerState> textureSampler;
  32. DKObject<DKShaderBindingSet> bindSet;
  33. DKObject<DKData> shaderData[static_cast<int>(DKShaderStage::Compute)];
  34. DKObject<DKShaderModule> shaderModule[static_cast<int>(DKShaderStage::Compute)];
  35. DKObject<DKShaderFunction> shaderFunction[static_cast<int>(DKShaderStage::Compute)];
  36. DKAabb aabb;
  37. };