Add renderpass abstraction

This commit is contained in:
Brad Davis 2018-10-28 19:49:01 -07:00 committed by Karol Suprynowicz
parent f6bbaa3fd2
commit bf354119aa
2 changed files with 104 additions and 0 deletions

View 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 };
}

View 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