mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Merge branch 'vulkan' of https://github.com/nikeinikei/love into vulkan
This commit is contained in:
@@ -58,32 +58,19 @@ namespace love {
|
||||
|
||||
void Graphics::initVulkan() {
|
||||
if (!init) {
|
||||
std::cout << "initVulkan" << std::endl;
|
||||
init = true;
|
||||
createVulkanInstance();
|
||||
std::cout << "create vulkan instance" << std::endl;
|
||||
createSurface();
|
||||
std::cout << "create surface" << std::endl;
|
||||
pickPhysicalDevice();
|
||||
std::cout << "create physical device" << std::endl;
|
||||
createLogicalDevice();
|
||||
std::cout << "create logical device" << std::endl;
|
||||
createSwapChain();
|
||||
std::cout << "create swap chain" << std::endl;
|
||||
createImageViews();
|
||||
std::cout << "create image views" << std::endl;
|
||||
createRenderPass();
|
||||
std::cout << "create render pass" << std::endl;
|
||||
createGraphicsPipeline();
|
||||
std::cout << "create graphics pipeline" << std::endl;
|
||||
createFramebuffers();
|
||||
std::cout << "create frame buffers" << std::endl;
|
||||
createCommandPool();
|
||||
std::cout << "create command pool" << std::endl;
|
||||
createCommandBuffers();
|
||||
std::cout << "create command buffers" << std::endl;
|
||||
createSyncObjects();
|
||||
std::cout << "create sync objects" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +79,7 @@ namespace love {
|
||||
}
|
||||
|
||||
love::graphics::Buffer* Graphics::newBuffer(const love::graphics::Buffer::Settings& settings, const std::vector<love::graphics::Buffer::DataDeclaration>& format, const void* data, size_t size, size_t arraylength) {
|
||||
return new Buffer(this, settings, format, data, size, arraylength);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Graphics::present(void* screenshotCallbackdata) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
#include "Graphics.h"
|
||||
|
||||
#include <shaderc/shaderc.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
@@ -11,28 +9,12 @@
|
||||
namespace love {
|
||||
namespace graphics {
|
||||
namespace vulkan {
|
||||
static shaderc_shader_kind getShaderStage(ShaderStageType stage) {
|
||||
switch (stage) {
|
||||
case SHADERSTAGE_VERTEX: return shaderc_vertex_shader;
|
||||
case SHADERSTAGE_PIXEL: return shaderc_fragment_shader;
|
||||
case SHADERSTAGE_COMPUTE: return shaderc_compute_shader;
|
||||
default:
|
||||
throw love::Exception("unknown exception");
|
||||
}
|
||||
}
|
||||
|
||||
ShaderStage::ShaderStage(love::graphics::Graphics* gfx, ShaderStageType stage, const std::string& glsl, bool gles, const std::string& cachekey)
|
||||
: love::graphics::ShaderStage(gfx, stage, glsl, gles, cachekey) {
|
||||
using namespace shaderc;
|
||||
|
||||
Compiler compiler{};
|
||||
auto result = compiler.CompileGlslToSpv(glsl, shaderc_vertex_shader, "shader.glsl");
|
||||
std::vector<uint32_t> code(result.begin(), result.end());
|
||||
|
||||
VkShaderModuleCreateInfo createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
createInfo.codeSize = code.size() * sizeof(unsigned int);
|
||||
createInfo.pCode = reinterpret_cast<const uint32_t*>(code.data());
|
||||
createInfo.codeSize = 0;
|
||||
createInfo.pCode = nullptr;
|
||||
|
||||
Graphics* vkGfx = (Graphics*)gfx;
|
||||
device = vkGfx->getDevice();
|
||||
|
||||
Reference in New Issue
Block a user