载入中...
搜索中...
未找到
Graphics.h
浏览该文件的文档.
36 static std::vector<vk::VertexInputAttributeDescription> getAttributeDescription(uint32_t binding) {
56 static std::vector<vk::VertexInputAttributeDescription> getAttributeDescription(uint32_t binding) {
77 static std::vector<vk::VertexInputAttributeDescription> getAttributeDescription(uint32_t binding) {
219 void drawTexturedRect(Texture *texture, float x, float y, float w, float h, const Color &color) override;
220 void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w, float h,
222 void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0, float v0,
233 void drawTexturedRectShaderDepth(Texture *color, Texture *depth, Shader *shader, float x, float y,
235 void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h,
240 Shader *newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath) override;
255 bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ, const float *uvST,
271 void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint) override;
284 void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage,
295 void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo = nullptr) override;
302 void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ,
317 void clear(std::optional<Color> color, std::optional<int> stencil, std::optional<double> depth) override;
391 vkb::BoundSet mesh3dClusteredSetFor(GpuTexture *gpuTex, GpuTexture *normalTex, GpuTexture *envTex,
395 vk::Pipeline createTexturedStylePipeline(const std::vector<uint32_t> &vert, const std::vector<uint32_t> &frag,
398 vk::Pipeline createMesh3DStylePipeline(const std::vector<uint32_t> &vert, const std::vector<uint32_t> &frag,
Accumulates solid / textured quads in logical (Y-down) coordinates. Used by RenderSystem; not a publi...
Definition Batcher.h:22
Definition Canvas.h:16
Definition Graphics.h:56
virtual void setVSync(bool enabled)
Prefer uncapped present (IMMEDIATE/MAILBOX) when false, vsync (MAILBOX/FIFO) when true....
Definition Graphics.h:604
virtual void setMsaaSamples(int samples)
Hardware MSAA sample count for the 3D scene color pass (0 disables, then 2/4/8 are used when the devi...
Definition Graphics.h:612
virtual void setScreenReadbackEnabled(bool enabled)
When true, each present copies the swapchain to a CPU buffer for getPixel/newImageData....
Definition Graphics.h:591
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:17
void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ, Texture *albedo=nullptr, float tintR=1.f, float tintG=1.f, float tintB=1.f) override
Definition Graphics3D.cpp:559
void beginShadowPass(int cascadeIndex) override
Depth-only shadow pass for one cascade layer (0..2). Draws are recorded into the next begin3DFrame co...
Definition Graphics3D.cpp:504
float getMaxAnisotropy() const override
Device max supported anisotropy (1 if unsupported). Valid after initWithWindow.
Definition Graphics2D.cpp:517
void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color) override
Draw a textured sub-rect (atlas / tile UVs). texture may be null → solid.
Definition Graphics2D.cpp:866
void begin3DFrame() override
Begin a 3D frame: shadow/gbuffer (if pending) then a sampleable scene color pass (color+depth)....
Definition Graphics3D.cpp:59
Shader * newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath) override
Load SPIR-V from files via Filesystem (empty vertPath → default textured vert).
Definition Graphics2D.cpp:1076
bool releaseMesh(Mesh *mesh) override
Eagerly releases a mesh created by this Graphics.
Definition GraphicsMesh.cpp:312
void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f) override
Parallax occlusion mapping for the next default mesh draw. scale: UV displacement strength (0=off)....
Definition Graphics3D.cpp:647
void onNativeWindowDestroyed() override
Called by the Window module when the native window backing the render surface is destroyed (window cl...
Definition Graphics.cpp:272
void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage, float detail) override
Dynamic cloud shadows cast on the ground by the default PBR mesh path. strength 0 disables (no change...
Definition Graphics3D.cpp:684
void draw(eve::graphics::Graphics *gfx, const glm::mat4 &matrix) const override
Draws the object with the specified transformation matrix.
Definition Graphics.cpp:577
Mesh * newMeshSphere(int slices=32, int stacks=16) override
Procedural UV sphere (radius 1, Y-up). Owned by Graphics. slices = longitude divisions,...
Definition GraphicsMesh.cpp:338
void drawVoxelFaceInstances(const uint32_t *packed, int count, float originX, float originY, float originZ, const std::string &faceDir, Texture *atlas, int tilesPerRow=16, const uint32_t *ao=nullptr) override
Instanced voxel face rectangles (32-bit packed instances). ao: optional per-instance ambient-occlusio...
Definition Graphics3D.cpp:402
void end3DFrameToCanvas() override
Definition Graphics3D.cpp:224
Texture * getTexture() override
Sampleable color buffer; screen Canvas returns nullptr.
Definition GraphicsPipeline.cpp:1384
void setLighting2D(const Lighting2DUBO &ubo) override
Upload per-frame / per-canvas 2D lighting constants for subsequent lit draws.
Definition Graphics2D.cpp:926
Canvas * getCanvas() const override
Definition Graphics2D.cpp:426
image::ImageData * renderEntityIdMask(const std::vector< eve::graphics::Graphics::EntityIdDraw > &draws, const glm::mat4 &viewProj, int width, int height) override
Definition Graphics2D.cpp:246
int getMsaaSamples() const override
Definition Graphics.h:195
void pushValidationScope() override
Backend hooks so the platform-independent render3D() can wrap its work in a GPU validation error scop...
Definition Graphics.h:202
void setMesh3DShadowReceive(bool receive) override
Per-draw: when false, shadow sampling is forced off for the next mesh draw.
Definition Graphics3D.cpp:502
bool bakeMeshMorph(Mesh *mesh) override
If mesh morph weights are dirty, bake blended positions and upload to the GPU VBO....
Definition GraphicsMesh.cpp:244
void setMesh3DLighting(const Lighting3DPack &pack) override
Per-frame ambient + up to 8 lights packed into Mesh3DUBO.
Definition Graphics3D.cpp:658
Color getPixel(int x, int y) override
Definition Graphics2D.cpp:217
void setMesh3DEnv(Texture *cube, float intensity) override
Specular IBL environment for subsequent default mesh draws. cube must be from newCubemap (or nullptr ...
Definition Graphics3D.cpp:494
uint32_t getSwapchainImageCount() const
Definition Graphics.h:338
const vkb::BuiltRenderPass & getOffscreen3DRenderPass()
Definition Graphics.h:325
Texture * getSceneColorTexture() override
Sampleable 3D color target for the current frame (RGB = lit, A = linear depth). Valid after begin3DFr...
Definition Graphics.cpp:410
Shader * newShader(const std::string &vertGlsl, const std::string &fragGlsl) override
Compile GLSL source with glslc (must be on PATH). Empty vertGlsl → default textured vert....
Definition Graphics2D.cpp:1084
void setMsaaSamples(int samples) override
Hardware MSAA sample count for the 3D scene color pass (0 disables, then 2/4/8 are used when the devi...
Definition Graphics.h:190
std::string getBackendName() const override
Renderer backend id used by sibling modules (e.g. Gpgpu).
Definition Graphics.cpp:56
bool isCanvasActive() const override
Definition Graphics2D.cpp:422
void endGBufferPass() override
Definition Graphics3D.cpp:599
bool reloadTextureFromFile(const std::string &filename) override
Reload a path-cached texture from disk in place (pointer stable). False if unbound.
Definition Graphics2D.cpp:839
vk::CommandPool getUploadPool() const
Definition Graphics.h:321
friend class OffscreenCanvas
Definition Graphics.h:340
void initWithWindow(void *nativeWindow) override
Bind to an existing native window (SDL_Window*) and create Vulkan device/swapchain....
Definition Graphics.cpp:139
Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv) override
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
Definition Graphics2D.cpp:1092
void endShadowPass() override
Definition Graphics3D.cpp:531
void drawTexturedRectShaderUV(Texture *texture, Shader *shader, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color, bool rotatedUV=false, BlendMode blend=BlendMode::Alpha) override
UV draw with an explicit Shader (nullptr = default textured pipeline).
Definition Graphics2D.cpp:871
vk::RenderPass getUiMsaaRenderPass() const
Definition Graphics.h:328
Mesh * newMeshCylinder(int slices=32, int stacks=1, bool caps=true) override
Procedural Y-up cylinder (radius 1, height 2 centered at origin). slices = longitude divisions; stack...
Definition GraphicsMesh.cpp:422
void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f) override
Texture cell bombing for the next default mesh draw (breaks tiling). cellScale: cells per UV unit (ty...
Definition Graphics3D.cpp:639
void setScreenReadbackEnabled(bool enabled) override
When true, each present copies the swapchain to a CPU buffer for getPixel/newImageData....
Definition Graphics.h:181
Canvas * newCanvas(int width, int height) override
Create an offscreen render target (sampleable). Owned by Graphics.
Definition Graphics2D.cpp:398
void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP) override
Definition Graphics3D.cpp:514
Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount) override
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
Definition GraphicsMesh.cpp:207
void setViewportSize(int width, int height, int pixelwidth, int pixelheight) override
Sets the current graphics display viewport dimensions.
Definition Graphics2D.cpp:430
void setMesh3DCameraPos(const glm::vec3 &eye) override
Camera eye used by mesh shaders that need view/rim (stored in Mesh3DUBO).
Definition Graphics3D.cpp:256
bool replaceTexturePixels(Texture *tex, image::ImageData *data)
Definition Graphics2D.cpp:754
Shader * newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl) override
Definition Graphics2D.cpp:1192
void begin3DFrameToCanvas(Canvas *canvas) override
Open a 3D render pass targeting an offscreen Canvas (color + depth) at the canvas size....
Definition Graphics3D.cpp:169
Mesh * newMeshFromAssimp(const ::aiMesh &mesh) override
Definition GraphicsMesh.cpp:51
void setMesh3DViewProj(const glm::mat4 &viewProj) override
Definition Graphics3D.cpp:752
image::ImageData * readGBufferToImageData(const std::string &name) override
Read a G-buffer attachment back to CPU as RGBA8. name is one of "depth" (RGBA8 linear depth),...
Definition Graphics2D.cpp:357
const vkb::BuiltRenderPass & getOffscreenRenderPass() const
Definition Graphics.h:324
void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader) override
Draw mesh with an explicit Mesh3D Shader (nullptr = default PBR pipeline).
Definition GraphicsMesh.cpp:535
vk::DescriptorSetLayout getTexSetLayout() const
Definition Graphics.h:322
void setMesh3DShadows(const ShadowUpload &upload) override
Upload CSM constants for subsequent default mesh draws (active=false disables).
Definition Graphics3D.cpp:500
void drawTexturedRect(Texture *texture, float x, float y, float w, float h, const Color &color) override
Definition Graphics2D.cpp:857
void beginGBufferPass(int width, int height) override
Depth/normal(/albedo) fill pass for mid/post effects. One-shot submit (like shadow); call before begi...
Definition Graphics3D.cpp:548
void setTextureSampler(Texture *texture, const TextureSampler &sampler) override
Recreate the sampler for an existing texture (keeps image / mip chain). No-op when texture is null or...
Definition Graphics2D.cpp:699
void drawTexturedRectShaderUVRotated(Texture *texture, Shader *shader, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, const Color &color, bool rotatedUV=false, BlendMode blend=BlendMode::Alpha) override
UV draw rotated degrees clockwise (screen Y-down) around the rect center. texture may be null → solid...
Definition Graphics2D.cpp:888
bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount) override
In-place update of a mesh's vertex/index data (CPU -> host-visible VBO). Mirrors bakeMeshMorph: the u...
Definition GraphicsMesh.cpp:280
void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) override
Directional light for subsequent drawMesh calls (world-space direction toward surface).
Definition Graphics3D.cpp:248
void setMesh3DHeightTexture(Texture *height) override
Optional height map for parallax (R channel; nullptr = flat / off).
Definition Graphics3D.cpp:490
vk::RenderPass getSwapchainRenderPass() const
Definition Graphics.h:327
void popValidationScope() override
Definition Graphics.h:203
void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint) override
Draw one mesh with model matrix. Requires begin3DFrame() (or an open swapchain pass).
Definition GraphicsMesh.cpp:531
image::ImageData * newImageData() override
Definition Graphics2D.cpp:208
void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ, Texture *albedo=nullptr, float tintR=1.f, float tintG=1.f, float tintB=1.f) override
GBuffer fill with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): same ou...
Definition Graphics3D.cpp:578
vkb::Swapchain & getSwapchain()
Definition Graphics.h:336
void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w, float h, const Color &color) override
Draw with an explicit Shader (nullptr = default textured pipeline).
Definition Graphics2D.cpp:861
void ensureUiColorResources()
Create the UI MSAA render pass (once) and its color targets for ImGui init.
Definition Graphics.h:332
void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color) override
Lit 2D draw (albedo + normal map). Uses Lighting2DUBO from setLighting2D. normal may be null → treate...
Definition Graphics2D.cpp:934
Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces) override
Create an RGBA8 cubemap from 6 faces packed as +X,-X,+Y,-Y,+Z,-Z (each faceSize×faceSize,...
Definition Graphics2D.cpp:626
void drawTexturedRectShaderDepth(Texture *color, Texture *depth, Shader *shader, float x, float y, float w, float h, const Color &tint) override
Fullscreen/post draw sampling color at binding 0 and depth at binding 1 (hardware D32,...
Definition Graphics2D.cpp:907
Shader * newShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv) override
Create a custom 2D shader from SPIR-V words (vert + frag). Owned by Graphics. Vertex stage may be emp...
Definition Graphics2D.cpp:1045
void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color, BlendMode blend=BlendMode::Alpha) override
Rotated solid quad degrees clockwise (screen Y-down) around (cx, cy).
Definition Graphics2D.cpp:504
Texture * newTextureFromFile(const std::string &filename) override
Definition Graphics2D.cpp:819
void setVSync(bool enabled) override
Prefer uncapped present (IMMEDIATE/MAILBOX) when false, vsync (MAILBOX/FIFO) when true....
Definition Graphics.h:185
void setMesh3DView(const glm::mat4 &view) override
Camera view matrix for subsequent drawMesh (view-space depth / CSM select).
Definition Graphics3D.cpp:756
void setMesh3DClusteredActive(bool active) override
Cheap per-draw toggle for the already-uploaded clustered light table. Unlike setMesh3DClusteredLighti...
Definition GraphicsPipeline.cpp:1156
void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo=nullptr) override
Shadow pass draw with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): tra...
Definition Graphics3D.cpp:520
bool releaseTexture(Texture *texture) override
Eagerly releases a texture created by this Graphics.
Definition Graphics2D.cpp:715
void setMesh3DNormalTexture(Texture *normal) override
Optional normal map for the next drawMesh / drawMeshShader (nullptr = flat).
Definition Graphics3D.cpp:488
vk::Format getDepthFormat() const
Definition Graphics.h:326
Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl) override
Create a Mesh3D custom shader from WGSL source (WebGPU backend). The WGSL must declare the engine's F...
Definition Graphics2D.cpp:1200
void requestSurfaceRecreate() override
Request recreation of the platform render surface on the next frame (Android background/foreground de...
Definition Graphics.h:179
void setMesh3DClip(float nearZ, float farZ) override
Near/far used to pack linear depth into scene color A (SSGI).
Definition Graphics3D.cpp:760
Shader * newHairShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv) override
Hair/fur card shader (alpha blend + Kajiya-Kay). Empty vert → mesh3d_hair.vert. Owned by Graphics.
Definition Graphics2D.cpp:1128
Texture * newTexture(int width, int height, const uint8_t *rgba, bool repeatU=false, bool repeatV=false) override
Definition Graphics2D.cpp:572
vk::DescriptorPool getDescriptorPool() const
Definition Graphics.h:323
void setMesh3DSceneDepth(Texture *depth) override
Optional scene hardware depth (G-buffer hwDepth, Vulkan NDC z) bound to mesh3d shader binding 7....
Definition Graphics3D.cpp:492
bool releaseShader(Shader *shader) override
Eagerly releases a shader created by this Graphics.
Definition Graphics2D.cpp:1161
void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload) override
Enable clustered forward path for subsequent default mesh draws (SSBO light lists)....
Definition GraphicsPipeline.cpp:1150
void setMesh3DMaterial(float metallic, float roughness) override
Metallic (0..1) and roughness (0..1) for the next default mesh draw.
Definition Graphics3D.cpp:632
void clear(std::optional< Color > color, std::optional< int > stencil, std::optional< double > depth) override
Definition Graphics2D.cpp:481
vk::SampleCountFlagBits getUiMsaaSamples() const
Sample count the UI MSAA pass runs with (matches getUiMsaaRenderPass).
Definition Graphics.h:330
void drawSolidRect(float x, float y, float w, float h, const Color &color, BlendMode blend=BlendMode::Alpha) override
Internal immediate-mode helper used by RenderSystem / Batcher.
Definition Graphics2D.cpp:492
Definition VulkanSequence.h:8
glm::vec4 Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Definition ClusteredLight.h:32
Definition Light.h:20
Definition Light.h:90
Definition Shadow.h:25
Options for Graphics::newTexture / newCubemap. When generateMipmaps is true and sampler....
Definition TextureSampler.h:104
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...
Definition TextureSampler.h:27
static vk::VertexInputBindingDescription getBindingDescription(uint32_t binding)
Definition Graphics.h:29
static std::vector< vk::VertexInputAttributeDescription > getAttributeDescription(uint32_t binding)
Definition Graphics.h:36
Definition Graphics.h:140
static constexpr size_t kDynamicVertexCopies
Ring copies for per-frame updated meshes (skin/morph/sprite stack). Writing the next copy never races...
Definition Graphics.h:145
uint64_t dynamicWriteCount
Number of dynamic updates; ring slot = count % kDynamicVertexCopies.
Definition Graphics.h:154
std::array< vkb::GenericBuffer, kDynamicVertexCopies > dynIndices
Definition Graphics.h:149
std::array< vkb::HostVertexBuffer, kDynamicVertexCopies > dynVertices
Definition Graphics.h:148
std::vector< uint32_t > cpuIndices
CPU index copy for dynamic meshes (also normalizes 16-bit static indices to 32-bit ring buffers).
Definition Graphics.h:152
vk::Pipeline mesh3dPipeline
Definition Graphics.h:163
vk::Pipeline mesh3dXrayPipeline
Definition Graphics.h:164
vk::PipelineLayout pipelineLayout
Definition Graphics.h:165
vk::Pipeline offscreenPipeline
Definition Graphics.h:162
vk::Pipeline swapchainPipeline
Definition Graphics.h:161
vk::ImageView imageView() const
Definition Graphics.h:134
vkb::TextureImageCube cubeImage
Definition Graphics.h:124
vkb::BoundSet descriptorSet
Definition Graphics.h:127
Light3DGpu lights[Lighting3DPack::kMaxLights]
Definition Graphics.h:95
static std::vector< vk::VertexInputAttributeDescription > getAttributeDescription(uint32_t binding)
Definition Graphics.h:77
static vk::VertexInputBindingDescription getBindingDescription(uint32_t binding)
Definition Graphics.h:70
static std::vector< vk::VertexInputAttributeDescription > getAttributeDescription(uint32_t binding)
Definition Graphics.h:56
static vk::VertexInputBindingDescription getBindingDescription(uint32_t binding)
Definition Graphics.h:49