mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 19:09:25 +02:00
Ordering them before the imports in the same file was not enough: a project header on line 1 can import a module several levels down whose global module fragment already pulled in the same standard header, and that include guard does not cross the module boundary. Putting them first means the guard is set before anything can import. Skips vendored single-header libraries and anything inside an #if.
62 lines
2.1 KiB
C++
62 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <array>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <nvrhi/nvrhi.h>
|
|
|
|
#include "nvrenderer/nvrenderer.h"
|
|
|
|
struct ShaderDefine {
|
|
std::string m_name;
|
|
std::string m_definition;
|
|
};
|
|
|
|
class NvRendererBackend {
|
|
protected:
|
|
friend class NvRenderer;
|
|
NvRenderer *m_renderer;
|
|
virtual std::string LoadShaderBlob(const std::string &fileName,
|
|
const std::string &entryName) = 0;
|
|
virtual bool BeginFrame() = 0;
|
|
virtual void Present() = 0;
|
|
virtual void UpdateWindowSize() = 0;
|
|
virtual int GetCurrentBackBufferIndex() = 0;
|
|
virtual int GetBackBufferCount() = 0;
|
|
virtual nvrhi::TextureHandle GetBackBuffer(int index) = 0;
|
|
class NvRendererMessageCallback *GetMessageCallback() const {
|
|
return m_renderer->m_message_callback.get();
|
|
}
|
|
void AddMaterialShaderBlob(std::string_view material, std::string_view pass,
|
|
std::string blob, const std::string &entrypoint);
|
|
void AddShaderBlob(std::string_view shader, std::string blob,
|
|
const std::string &entrypoint);
|
|
virtual void LoadShaderBlobs() {}
|
|
struct ShaderBlob {
|
|
std::string m_entrypoint;
|
|
std::string m_blob;
|
|
};
|
|
std::unordered_map<std::string, ShaderBlob> m_shader_blobs;
|
|
std::unordered_map<
|
|
std::string,
|
|
std::array<ShaderBlob, NvRenderer::Constants::NumMaterialPasses()>>
|
|
m_material_blobs;
|
|
|
|
public:
|
|
void Init();
|
|
virtual bool IsHDRDisplay() const { return false; }
|
|
// nvrhi::DeviceHandle m_device;
|
|
virtual nvrhi::IDevice *GetDevice() { return nullptr; };
|
|
std::vector<nvrhi::FramebufferHandle> m_framebuffers;
|
|
nvrhi::FramebufferHandle GetCurrentFramebuffer();
|
|
nvrhi::ShaderHandle CreateShader(const std::string &name,
|
|
nvrhi::ShaderType type);
|
|
nvrhi::ShaderHandle CreateMaterialShader(const std::string &name,
|
|
NvRenderer::RenderPassType pass);
|
|
};
|
|
|
|
class NvRendererMessageCallback : public nvrhi::IMessageCallback {
|
|
virtual void message(nvrhi::MessageSeverity severity,
|
|
const char *messageText) override;
|
|
}; |