mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 13:12:52 +02:00
Add renderpass abstraction
This commit is contained in:
parent
f6bbaa3fd2
commit
bf354119aa
2 changed files with 104 additions and 0 deletions
38
libraries/gpu/src/gpu/Renderpass.cpp
Normal file
38
libraries/gpu/src/gpu/Renderpass.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2018/10/21
|
||||
// Copyright 2013-2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "Renderpass.h"
|
||||
|
||||
using namespace gpu;
|
||||
|
||||
Attachment::Attachment() {
|
||||
}
|
||||
|
||||
Attachment::Attachment(const Element& element, LoadOp load, StoreOp store, LoadOp stencilLoad, StoreOp stencilStore) :
|
||||
loadOp(load), storeOp(store), stencilLoadOp(stencilLoad), stencilStoreOp(stencilStore) {
|
||||
}
|
||||
|
||||
uint32_t Attachment::getRaw() const {
|
||||
throw std::runtime_error("not implemented");
|
||||
}
|
||||
|
||||
void Attachment::setRaw(uint32_t raw) {
|
||||
throw std::runtime_error("not implemented");
|
||||
}
|
||||
|
||||
void Renderpass::addColorAttachment(const Element& element, LoadOp load, StoreOp store) {
|
||||
_colorAttachments.emplace_back(element, load, store);
|
||||
}
|
||||
|
||||
void Renderpass::setDepthStencilAttachment(const Element& element,
|
||||
LoadOp load,
|
||||
StoreOp store,
|
||||
LoadOp stencilLoad,
|
||||
StoreOp stencilStore) {
|
||||
_depthStencilAttachment = Attachment{ element, load, store, stencilLoad, stencilStore };
|
||||
}
|
66
libraries/gpu/src/gpu/Renderpass.h
Normal file
66
libraries/gpu/src/gpu/Renderpass.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2018/10/21
|
||||
// Copyright 2013-2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#pragma once
|
||||
#ifndef hifi_gpu_Renderpass_h
|
||||
#define hifi_gpu_Renderpass_h
|
||||
|
||||
#include <assert.h>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "Format.h"
|
||||
|
||||
namespace gpu {
|
||||
|
||||
enum class LoadOp
|
||||
{
|
||||
Load = 0,
|
||||
Clear = 1,
|
||||
DontCare = 2,
|
||||
};
|
||||
|
||||
enum class StoreOp
|
||||
{
|
||||
Store = 0,
|
||||
DontCare = 1,
|
||||
};
|
||||
|
||||
struct Attachment {
|
||||
Attachment();
|
||||
Attachment(const Element& element, LoadOp loadOp, StoreOp storeOp, LoadOp stencilLoadOp = LoadOp::DontCare, StoreOp stencilStoreOp = StoreOp::DontCare);
|
||||
Element element;
|
||||
LoadOp loadOp{ LoadOp::DontCare };
|
||||
StoreOp storeOp{ StoreOp::DontCare };
|
||||
LoadOp stencilLoadOp{ LoadOp::DontCare };
|
||||
StoreOp stencilStoreOp{ StoreOp::DontCare };
|
||||
|
||||
uint32_t getRaw() const;
|
||||
void setRaw(uint32_t raw);
|
||||
};
|
||||
|
||||
class Renderpass {
|
||||
public:
|
||||
using Attachments = std::vector<Attachment>;
|
||||
|
||||
Renderpass();
|
||||
virtual ~Renderpass();
|
||||
|
||||
void addColorAttachment(const Element& element, LoadOp load, StoreOp store);
|
||||
void setDepthStencilAttachment(const Element& element, LoadOp load, StoreOp store, LoadOp stencilLoadOp = LoadOp::DontCare, StoreOp stencilStoreOp = StoreOp::DontCare);
|
||||
|
||||
protected:
|
||||
Attachments _colorAttachments;
|
||||
Attachment _depthStencilAttachment;
|
||||
// TODO if we want to start working with input attachments and multisampling resolve attachments, we'll need to extend this class
|
||||
};
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue