载入中...
搜索中...
未找到

Custom GPU program. 更多...

#include <Shader.h>

Public 类型

enum class  Kind { eSprite2D , eMesh3D }
 Kind public API. 更多...
 
enum  ShaderType {
  eCompute , eVertex , eFragment , eGeometry ,
  eTessCtrl , eTessEval
}
 

Public 成员函数

 Shader ()
 
 ~Shader ()
 
 Shader (const Shader &)=delete
 
Shader & operator= (const Shader &)=delete
 
Kind getKind () const
 
void setKind (Kind k)
 
void setXray (bool x)
 X-ray mesh shader. When true, drawMeshShader renders this mesh a second pass over the already-lit scene with depth test/write disabled and alpha blending, letting occluded (behind-building) silhouettes show through. The shader itself samples G-buffer scene depth to discard visible pixels.
 
bool isXray () const
 
const MeshShaderRasterState & meshRasterState () const noexcept
 Read the committed raster snapshot; render-thread affinity matches the owning Graphics.
 
int declareFloat (const std::string &name)
 Reserve sequential float slots in the push-constant block. Returns start index.
 
int declareVec2 (const std::string &name)
 
int declareVec3 (const std::string &name)
 
int declareVec4 (const std::string &name)
 
int declareMatrix (const std::string &name)
 
void sendFloat (const std::string &name, float x)
 
void sendVec2 (const std::string &name, float x, float y)
 
void sendVec3 (const std::string &name, float x, float y, float z)
 
void sendVec4 (const std::string &name, float x, float y, float z, float w)
 
void sendMatrix (const std::string &name, const glm::mat4 &m)
 
int sendToVar (const std::string &name, const void *data, size_t size)
 Low-level blob write into a declared uniform (size must match declaration).
 
int getFromVar (const std::string &name, void *data, size_t size) const
 
bool hasUniform (const std::string &name) const
 
int getUniformIndex (const std::string &name) const
 
int getUniformFloatCount (const std::string &name) const
 
const float * pushConstantData () const
 
void setPushConstantBlock (const std::array< float, kMaxFloats > &values) noexcept
 Replace the entire fixed push-constant ABI without name lookup or allocation.
 
uint32_t pushConstantSize () const
 
int usedFloats () const
 
Result< void > setMeshTexture (std::size_t slot, Texture *texture)
 Assign a borrowed custom-mesh texture to a portable slot in [0,4).
 
Texture * meshTexture (std::size_t slot) const
 Return the borrowed texture assigned to a custom-mesh slot, or null.
 
const std::vector< uint32_t > & vertexSpirv () const
 
const std::vector< uint32_t > & fragmentSpirv () const
 
void setSpirv (std::vector< uint32_t > vert, std::vector< uint32_t > frag)
 

Public 属性

BlendMode meshBlend = BlendMode::Opaque
 Backend-owned surface state retained across pipeline recreation.
 
bool meshDepthWrite = true
 Backend-owned depth-write state for custom mesh programs.
 
bool meshDoubleSided = true
 Backend-owned culling state for custom mesh programs.
 
void * gpuHandle = nullptr
 

静态 Public 属性

static constexpr int kMaxFloats = 32
 
static constexpr std::size_t kMaxMeshTextures = 4
 
static constexpr uint32_t kPushConstantBytes = uint32_t(kMaxFloats * sizeof(float))
 

友元

class vulkan::Graphics
 

详细描述

Custom GPU program.

2D sprites (newShader / newShaderFromSpv): Vertex = TexturedVertex; MainTex @ set0 binding0; optional push-constant data[32].

3D meshes (newMeshShader / newMeshShaderFromSpv): Vertex = MeshVertex; Frame UBO @ binding0 + albedo @ binding1 (same as mesh3d); optional push-constant data[32] for style knobs.

Hair/fur cards (newHairShader / newHairShaderFromSpv): Same layout as mesh shaders; pipeline uses alpha blend, no back-face cull, no depth write.

Stylized grass (newGrassShader): Mesh3D layout + CSM shadow bindings. Alpha-tested billboards (depth write on). See graphics/Grass.h.

在文件 Shader.h 第 39 行定义.

成员枚举类型说明

◆ Kind

enum class eve::graphics::Shader::Kind
strong

Kind public API.

枚举值
eSprite2D 
eMesh3D 

在文件 Shader.h 第 46 行定义.

◆ ShaderType

枚举值
eCompute 
eVertex 
eFragment 
eGeometry 
eTessCtrl 
eTessEval 

在文件 Shader.h 第 48 行定义.

构造及析构函数说明

◆ Shader() [1/2]

eve::graphics::Shader::Shader ( )
default

◆ ~Shader()

eve::graphics::Shader::~Shader ( )
default

◆ Shader() [2/2]

eve::graphics::Shader::Shader ( const Shader &  )
delete

成员函数说明

◆ declareFloat()

int eve::graphics::Shader::declareFloat ( const std::string &  name)

◆ declareMatrix()

int eve::graphics::Shader::declareMatrix ( const std::string &  name)

在文件 Shader.cpp 第 47 行定义.

引用了 name.

◆ declareVec2()

int eve::graphics::Shader::declareVec2 ( const std::string &  name)

在文件 Shader.cpp 第 44 行定义.

引用了 name.

◆ declareVec3()

int eve::graphics::Shader::declareVec3 ( const std::string &  name)

在文件 Shader.cpp 第 45 行定义.

引用了 name.

被这些函数引用 eve::graphics::newWaterfallShader() , 以及 eve::graphics::newWaterShader().

◆ declareVec4()

int eve::graphics::Shader::declareVec4 ( const std::string &  name)

在文件 Shader.cpp 第 46 行定义.

引用了 name.

被这些函数引用 eve::procgen::Procgen::createTerrainMaterialShader().

◆ fragmentSpirv()

const std::vector< uint32_t > & eve::graphics::Shader::fragmentSpirv ( ) const
inline

在文件 Shader.h 第 137 行定义.

被这些函数引用 eve::graphics::vulkan::Graphics::replaceShaderFromGlsl().

◆ getFromVar()

int eve::graphics::Shader::getFromVar ( const std::string &  name,
void *  data,
size_t  size 
) const

◆ getKind()

Kind eve::graphics::Shader::getKind ( ) const
inline

在文件 Shader.h 第 63 行定义.

被这些函数引用 eve::graphics::vulkan::Graphics::replaceShaderFromGlsl().

◆ getUniformFloatCount()

int eve::graphics::Shader::getUniformFloatCount ( const std::string &  name) const

在文件 Shader.cpp 第 67 行定义.

引用了 name , 以及 u.

被这些函数引用 eve::graphics::applyGrassWind() , 以及 eve::graphics::applyTreeWind().

◆ getUniformIndex()

int eve::graphics::Shader::getUniformIndex ( const std::string &  name) const

在文件 Shader.cpp 第 61 行定义.

引用了 name , 以及 u.

被这些函数引用 eve::graphics::applyGrassWind() , 以及 eve::graphics::applyTreeWind().

◆ hasUniform()

◆ isXray()

bool eve::graphics::Shader::isXray ( ) const
inline

在文件 Shader.h 第 73 行定义.

◆ meshRasterState()

const MeshShaderRasterState & eve::graphics::Shader::meshRasterState ( ) const
inlinenoexcept

Read the committed raster snapshot; render-thread affinity matches the owning Graphics.

在文件 Shader.h 第 82 行定义.

◆ meshTexture()

Texture * eve::graphics::Shader::meshTexture ( std::size_t  slot) const
inline

Return the borrowed texture assigned to a custom-mesh slot, or null.

参数
slotPortable custom-mesh texture slot.
返回
Non-owning pointer valid while the caller-owned texture remains alive and assigned. @thread Graphics thread only.

在文件 Shader.h 第 132 行定义.

◆ operator=()

Shader & eve::graphics::Shader::operator= ( const Shader &  )
delete

◆ pushConstantData()

const float * eve::graphics::Shader::pushConstantData ( ) const
inline

在文件 Shader.h 第 105 行定义.

被这些函数引用 eve::graphics::GrassField::setTerrainDetailOverwrite().

◆ pushConstantSize()

uint32_t eve::graphics::Shader::pushConstantSize ( ) const
inline

在文件 Shader.h 第 114 行定义.

◆ sendFloat()

void eve::graphics::Shader::sendFloat ( const std::string &  name,
float  x 
)

在文件 Shader.cpp 第 95 行定义.

引用了 name, sendToVar() , 以及 x.

被这些函数引用 eve::graphics::Exposure::apply(), eve::graphics::GlobalIllumination::applyFromDepth(), eve::graphics::AmbientOcclusion::applyFromGBuffer(), eve::graphics::GlobalIllumination::applyFromScene(), eve::graphics::AmbientOcclusion::applyOverlay(), eve::graphics::GrassField::bake(), eve::graphics::AntiAliasing::beginTemporalFrame(), eve::graphics::Material::bind(), eve::graphics::Water::bindParams(), eve::graphics::Waterfall::bindParams(), eve::graphics::AmbientOcclusion::blur(), eve::graphics::DepthPyramid::build(), eve::graphics::Volumetric::projectDirectionalCookie(), eve::graphics::AmbientOcclusion::setCamera(), eve::graphics::GlobalIllumination::setCamera(), eve::graphics::ScreenSpaceReflection::setCamera(), eve::graphics::Volumetric::setCamera(), eve::graphics::Outline::setClip(), eve::graphics::Volumetric::setCloudCoverage(), eve::graphics::Volumetric::setCloudDensity(), eve::graphics::Volumetric::setCloudLayer(), eve::graphics::Volumetric::setCloudLightColor(), eve::graphics::Volumetric::setCloudScale(), eve::graphics::Volumetric::setCloudWind(), eve::graphics::Outline::setColor(), eve::graphics::Volumetric::setDensity(), eve::graphics::Outline::setDepthSensitivity(), eve::graphics::Outline::setDepthThreshold(), eve::graphics::ScreenSpaceReflection::setEnabled(), eve::graphics::AmbientOcclusion::setFloat(), eve::graphics::AntiAliasing::setFloat(), eve::graphics::GlobalIllumination::setFloat(), eve::graphics::Outline::setFloat(), eve::graphics::ScreenSpaceReflection::setFloat(), eve::graphics::Volumetric::setFloat(), eve::stylize::StylePass::setFloat(), eve::graphics::Volumetric::setFogColor(), eve::graphics::Volumetric::setFogEnd(), eve::graphics::Volumetric::setFogHeight(), eve::graphics::Volumetric::setFogHeightFalloff(), eve::graphics::Volumetric::setFogNoise(), eve::graphics::Volumetric::setFogStart(), eve::graphics::AmbientOcclusion::setIntensity(), eve::graphics::Volumetric::setIntensity(), eve::graphics::GlobalIllumination::setLightColor(), eve::graphics::GlobalIllumination::setLightDirection(), eve::graphics::Volumetric::setLightDirection(), eve::graphics::Volumetric::setLightScreenUV(), eve::graphics::Outline::setNormalThreshold(), eve::graphics::Volumetric::setShaftColor(), eve::graphics::Outline::setSoftness(), eve::graphics::AmbientOcclusion::setThickness(), eve::graphics::Outline::setWidth() , 以及 eve::graphics::Volumetric::uploadFroxel().

◆ sendMatrix()

void eve::graphics::Shader::sendMatrix ( const std::string &  name,
const glm::mat4 &  m 
)

◆ sendToVar()

int eve::graphics::Shader::sendToVar ( const std::string &  name,
const void *  data,
size_t  size 
)

Low-level blob write into a declared uniform (size must match declaration).

在文件 Shader.cpp 第 73 行定义.

引用了 name, size , 以及 u.

被这些函数引用 eve::graphics::applyGrassWind(), eve::graphics::applyTreeWind(), sendFloat(), sendMatrix(), sendVec2(), sendVec3() , 以及 sendVec4().

◆ sendVec2()

void eve::graphics::Shader::sendVec2 ( const std::string &  name,
float  x,
float  y 
)

在文件 Shader.cpp 第 97 行定义.

引用了 name, sendToVar(), v, x , 以及 y.

◆ sendVec3()

void eve::graphics::Shader::sendVec3 ( const std::string &  name,
float  x,
float  y,
float  z 
)

在文件 Shader.cpp 第 102 行定义.

引用了 name, sendToVar(), v, x, y , 以及 z.

被这些函数引用 eve::graphics::Water::bindParams() , 以及 eve::graphics::Waterfall::bindParams().

◆ sendVec4()

void eve::graphics::Shader::sendVec4 ( const std::string &  name,
float  x,
float  y,
float  z,
float  w 
)

在文件 Shader.cpp 第 107 行定义.

引用了 name, sendToVar(), v, w, x, y , 以及 z.

◆ setKind()

void eve::graphics::Shader::setKind ( Kind  k)
inline

在文件 Shader.h 第 64 行定义.

◆ setMeshTexture()

Result< void > eve::graphics::Shader::setMeshTexture ( std::size_t  slot,
Texture *  texture 
)

Assign a borrowed custom-mesh texture to a portable slot in [0,4).

参数
slotPortable custom-mesh texture slot.
textureBorrowed texture; null clears the slot.
返回
Success or InvalidArgument for an out-of-range slot. @lifetime The caller owns the texture and must keep it alive while assigned and used by a draw. @thread Graphics thread only; do not call while the shader is being submitted on another thread.

在文件 Shader.cpp 第 8 行定义.

引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument , 以及 eve::Result< T >::success().

◆ setPushConstantBlock()

void eve::graphics::Shader::setPushConstantBlock ( const std::array< float, kMaxFloats > &  values)
noexcept

Replace the entire fixed push-constant ABI without name lookup or allocation.

参数
valuesBorrowed values copied immediately; no storage is retained. @thread Graphics thread only, before draw submission. Existing named slots retain their offsets; the complete block is reserved and no further named slots can be declared.

在文件 Shader.cpp 第 20 行定义.

引用了 values.

◆ setSpirv()

void eve::graphics::Shader::setSpirv ( std::vector< uint32_t >  vert,
std::vector< uint32_t >  frag 
)
inline

在文件 Shader.h 第 139 行定义.

引用了 frag , 以及 vert.

◆ setXray()

void eve::graphics::Shader::setXray ( bool  x)
inline

X-ray mesh shader. When true, drawMeshShader renders this mesh a second pass over the already-lit scene with depth test/write disabled and alpha blending, letting occluded (behind-building) silhouettes show through. The shader itself samples G-buffer scene depth to discard visible pixels.

在文件 Shader.h 第 72 行定义.

引用了 x.

被这些函数引用 eve::stylize::createMeshShader().

◆ usedFloats()

int eve::graphics::Shader::usedFloats ( ) const
inline

在文件 Shader.h 第 115 行定义.

被这些函数引用 eve::graphics::applyGrassWind() , 以及 eve::graphics::applyTreeWind().

◆ vertexSpirv()

const std::vector< uint32_t > & eve::graphics::Shader::vertexSpirv ( ) const
inline

在文件 Shader.h 第 136 行定义.

被这些函数引用 eve::graphics::vulkan::Graphics::replaceShaderFromGlsl().

友元及相关函数文档

◆ vulkan::Graphics

friend class vulkan::Graphics
friend

在文件 Shader.h 第 148 行定义.

类成员变量说明

◆ gpuHandle

◆ kMaxFloats

constexpr int eve::graphics::Shader::kMaxFloats = 32
staticconstexpr

在文件 Shader.h 第 41 行定义.

被这些函数引用 eve::asset_graphics::EvpackShader::load().

◆ kMaxMeshTextures

constexpr std::size_t eve::graphics::Shader::kMaxMeshTextures = 4
staticconstexpr

在文件 Shader.h 第 42 行定义.

◆ kPushConstantBytes

constexpr uint32_t eve::graphics::Shader::kPushConstantBytes = uint32_t(kMaxFloats * sizeof(float))
staticconstexpr

在文件 Shader.h 第 43 行定义.

被这些函数引用 eve::graphics::vulkan::Graphics::replaceMeshShaderResources().

◆ meshBlend

BlendMode eve::graphics::Shader::meshBlend = BlendMode::Opaque

Backend-owned surface state retained across pipeline recreation.

在文件 Shader.h 第 76 行定义.

◆ meshDepthWrite

bool eve::graphics::Shader::meshDepthWrite = true

Backend-owned depth-write state for custom mesh programs.

在文件 Shader.h 第 78 行定义.

◆ meshDoubleSided

bool eve::graphics::Shader::meshDoubleSided = true

Backend-owned culling state for custom mesh programs.

在文件 Shader.h 第 80 行定义.


该类的文档由以下文件生成: