1
0
Fork 0

Vk LodModel

tmp
May B. 2020-10-12 10:18:24 +02:00
parent a774e99d7b
commit 7cdb3c636f
9 changed files with 44 additions and 17 deletions

View File

@ -178,9 +178,10 @@ void Client::run(server_handle* const localHandle) {
window.waitTargetFPS();
} while (!(inputs.isDown(Input::Quit) || window.shouldClose()));
options.contouring = state.contouring->getOptions();
world.reset();
render::UI::Unload();
render::Renderer::Unload();
window.destroy();
options.contouring = state.contouring->getOptions();
}

View File

@ -64,6 +64,13 @@ namespace contouring {
if (worker.joinable())
worker.join();
}
//TODO: prefer unique_ptr
for(auto& buffer: buffers) {
for(auto& val: buffer.second.second) {
delete val.second;
}
}
}
std::string FlatDualMC::getOptions() const {

View File

@ -271,6 +271,7 @@ void CommandCenter::recordModel(uint32_t i) {
vkCmdDrawIndexed(graphicsBuffers[i], static_cast<uint32_t>(buffer::vk::indices.size()), 1, 0, 0, 0);
}
void CommandCenter::startEntityPass(uint32_t) { }
void CommandCenter::recordIndicator(uint32_t, glm::mat4) { }
void CommandCenter::recordPostprocess(uint32_t idx, const Subpass& skyPass, bool skybox, glm::mat4, glm::mat4) {
vkCmdNextSubpass(graphicsBuffers[idx], VK_SUBPASS_CONTENTS_INLINE);
if (skybox) {

View File

@ -21,7 +21,7 @@ public:
void startWorldPass(uint32_t idx, const Subpass&);
void recordModel(uint32_t idx);
void startEntityPass(uint32_t idx);
//void recordModel(uint32_t idx);
void recordIndicator(uint32_t idx, glm::mat4 model);
void recordPostprocess(uint32_t idx, const Subpass&, bool skybox, glm::mat4 view, glm::mat4 proj);
void submitGraphics(uint32_t, VkSemaphore, VkSemaphore, VkFence);

View File

@ -398,6 +398,7 @@ bool Renderer::Load(Window& window, const renderOptions& opt, int samples) {
}
sInstance = new Renderer(instance, device, physicalInfo, opt);
LodModel::MakeDefault();
return true;
}
@ -438,10 +439,10 @@ std::function<size_t(render::Model *const, const std::vector<glm::mat4> &)> Rend
};
}
size_t Renderer::drawIndicatorCube(glm::mat4) {
size_t Renderer::drawIndicatorCube(glm::mat4 model) {
assert(currentImage < swapChain->getImageViews().size());
//commandCenter->drawIndicator(model);
commandCenter->recordIndicator(currentImage, model);
return 0;
}

View File

@ -49,7 +49,7 @@ memory::ptr render::vk::createBuffer(VkDeviceSize size, VkBufferUsageFlags usage
}
return memory;
}
memory::ptr createBuffers(const std::vector<Buffer::requirement>& requirements, VkMemoryPropertyFlags properties, std::vector<Buffer::info>& out) {
memory::ptr render::vk::createBuffers(const std::vector<Buffer::requirement>& requirements, VkMemoryPropertyFlags properties, std::vector<Buffer::info>& out) {
assert(!requirements.empty());
out.resize(requirements.size()+1);

View File

@ -89,4 +89,5 @@ private:
};
memory::ptr createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, const render::data_view view, Buffer::info &out);
memory::ptr createBuffers(const std::vector<Buffer::requirement> &requirements, VkMemoryPropertyFlags properties, std::vector<Buffer::info> &out);
}

View File

@ -7,4 +7,19 @@ std::unique_ptr<Shape> Shape::Create(const std::vector<glm::vec3>& vertices) {
data_view view(vertices);
auto mem = createBuffer(view.size, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, view, tmp);
return std::unique_ptr<Shape>(new Shape(tmp.ref, std::move(mem), vertices.size()));
}
std::unique_ptr<LodModel> LodModel::Create(const LodData& data) {
std::vector<vk::Buffer::info> tmp;
data_view vertices(data.first.vertices);
data_view indices(data.first.indices);
auto mem = createBuffers({{vertices.size, Usage::VERTEX, vertices}, {indices.size, Usage::INDEX, indices}}, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, tmp);
return std::unique_ptr<LodModel>(new LodModel(data.first.indices.size(), data.second, tmp.at(0).ref, tmp.at(1).ref, std::move(mem)));
}
std::unique_ptr<render::LodModel> createLodModelVk(const LodModel::LodData& data) {
return LodModel::Create(data);
}
void LodModel::MakeDefault() {
render::LodModel::createFunc = createLodModelVk;
}

View File

@ -62,20 +62,21 @@ private:
size_t indexSize;
GLuint vertexBufferId;
GLuint indexBufferId;
};
class LodModel final: public render::LodModel {
};*/
class LodModel final: public render::LodModel, public ShortIndexedVertexBuffer {
public:
LodModel(const LodData&);
~LodModel();
static std::unique_ptr<LodModel> Create(const LodData&);
static void MakeDefault();
size_t draw();
size_t drawInstanced(size_t count);
private:
GLuint vertexBufferId;
GLuint indexBufferId;
};*/
protected:
LodModel(size_t size, const std::vector<size_t>& off,
VkBuffer vertex, VkBuffer index, memory::ptr mem):
ShortIndexedVertexBuffer(vertex, index, std::move(mem))
{
indexSize = size;
offsets = off;
}
};
}