pub struct HotShader {
pub entry_name: String,
pub macro_definitions: Option<Vec<(String, Option<String>)>>,
pub optimization_level: Option<OptimizationLevel>,
pub path: PathBuf,
pub source_language: Option<SourceLanguage>,
pub specialization: Option<SpecializationMap>,
pub stage: ShaderStageFlags,
pub target_spirv: Option<SpirvVersion>,
pub warnings_as_errors: bool,
}Expand description
Describes a shader program which runs on some pipeline stage.
NOTE: When compiled on Apple platforms the macro MOLTEN_VK will be defined automatically.
This may be used to handle any differences introduced by SPIRV-Cross translation to Metal
Shading Language (MSL) at runtime.
Fields§
§entry_name: StringThe name of the entry point which will be executed by this shader.
The default value is main.
macro_definitions: Option<Vec<(String, Option<String>)>>Macro definitions.
optimization_level: Option<OptimizationLevel>Sets the optimization level.
path: PathBufShader source code path.
source_language: Option<SourceLanguage>Sets the source language.
specialization: Option<SpecializationMap>Data about Vulkan specialization constants.
§Examples
Basic usage (GLSL):
// fire.comp
#version 460 core
// Defaults to 6 if not set using HotShader specialization_info!
layout(constant_id = 0) const uint MY_COUNT = 6;
layout(set = 0, binding = 0) uniform sampler2D my_samplers[MY_COUNT];
void main()
{
// Code uses MY_COUNT number of my_samplers here
}use vk_graph::driver::shader::SpecializationMap;
use vk_graph_hot::HotShader;
// We instead specify 42 for MY_COUNT:
let shader = HotShader::new_compute("shaders/fire.comp")
.specialization(
SpecializationMap::new(42u32.to_ne_bytes())
.constant(0, 0, 4)
);stage: ShaderStageFlagsThe shader stage this structure applies to.
target_spirv: Option<SpirvVersion>Sets the target SPIR-V version.
warnings_as_errors: boolSets the compiler mode to treat all warnings as errors.
Implementations§
Source§impl HotShader
impl HotShader
Sourcepub fn new(stage: ShaderStageFlags, path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new(stage: ShaderStageFlags, path: impl AsRef<Path>) -> HotShaderBuilder
Specifies a shader with the given stage and shader code values.
Sourcepub fn new_any_hit(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_any_hit(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new ray tracing shader.
Sourcepub fn new_callable(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_callable(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new ray tracing shader.
Sourcepub fn new_closest_hit(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_closest_hit(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new ray tracing shader.
Sourcepub fn new_compute(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_compute(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new compute shader.
Sourcepub fn new_fragment(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_fragment(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new fragment shader.
Sourcepub fn new_geometry(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_geometry(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new geometry shader.
Sourcepub fn new_intersection(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_intersection(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new ray tracing shader.
Sourcepub fn new_mesh(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_mesh(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new mesh shader.
Sourcepub fn new_miss(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_miss(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new ray tracing shader.
Sourcepub fn new_ray_gen(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_ray_gen(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new ray tracing shader.
Sourcepub fn new_task(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_task(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new mesh task shader.
Sourcepub fn new_tessellation_ctrl(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_tessellation_ctrl(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new tessellation control shader.
Sourcepub fn new_tessellation_eval(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_tessellation_eval(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new tessellation evaluation shader.
Sourcepub fn new_vertex(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn new_vertex(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a new vertex shader.
Sourcepub fn from_path(path: impl AsRef<Path>) -> HotShaderBuilder
pub fn from_path(path: impl AsRef<Path>) -> HotShaderBuilder
Creates a shader using a shader kind inferred from the source code.