mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-29 17:52:18 +01:00
[dxvk] Added shader module
This commit is contained in:
parent
56ed80621d
commit
20048db69d
30
src/dxvk/dxvk_shader.cpp
Normal file
30
src/dxvk/dxvk_shader.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
#include "dxvk_shader.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
DxvkShader::DxvkShader(
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const SpirvCodeBuffer& code)
|
||||
: m_vkd(vkd) {
|
||||
TRACE(this);
|
||||
|
||||
VkShaderModuleCreateInfo info;
|
||||
info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
info.pNext = nullptr;
|
||||
info.flags = 0;
|
||||
info.codeSize = code.size();
|
||||
info.pCode = code.code();
|
||||
|
||||
if (m_vkd->vkCreateShaderModule(m_vkd->device(),
|
||||
&info, nullptr, &m_shader) != VK_SUCCESS)
|
||||
throw DxvkError("DxvkShader::DxvkShader: Failed to create shader");
|
||||
}
|
||||
|
||||
|
||||
DxvkShader::~DxvkShader() {
|
||||
TRACE(this);
|
||||
m_vkd->vkDestroyShaderModule(
|
||||
m_vkd->device(), m_shader, nullptr);
|
||||
}
|
||||
|
||||
}
|
41
src/dxvk/dxvk_shader.h
Normal file
41
src/dxvk/dxvk_shader.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "dxvk_include.h"
|
||||
|
||||
#include "./spirv/dxvk_spirv_code_buffer.h"
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
/**
|
||||
* \brief Shader module
|
||||
*
|
||||
* Manages a Vulkan shader module. This will not
|
||||
* perform any sort of shader compilation. Instead,
|
||||
* the context will create pipeline objects on the
|
||||
* fly when executing draw calls.
|
||||
*/
|
||||
class DxvkShader : public RcObject {
|
||||
|
||||
public:
|
||||
|
||||
DxvkShader(
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const SpirvCodeBuffer& code);
|
||||
~DxvkShader();
|
||||
|
||||
/**
|
||||
* \brief Shader module handle
|
||||
* \returns Shader module handle
|
||||
*/
|
||||
VkShaderModule handle() const {
|
||||
return m_shader;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Rc<vk::DeviceFn> m_vkd;
|
||||
VkShaderModule m_shader;
|
||||
|
||||
};
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user