载入中...
搜索中...
未找到
GraphicsDraw.cpp
浏览该文件的文档.
64Graphics::VertexArena& Graphics::currentVertexArena() { return vertexArenas[currentFrameSlot()]; }
110 if (!overlaySpans.empty() && overlaySpans.back().kind == OverlayKind::Solid && overlaySpans.back().index == idx) {
120 if (!overlaySpans.empty() && overlaySpans.back().kind == OverlayKind::Textured && overlaySpans.back().index == idx)
126 if (!overlaySpans.empty() && overlaySpans.back().kind == OverlayKind::Lit && overlaySpans.back().index == idx)
131void Graphics::drawSolidRect(float x, float y, float w, float h, const Color& color, BlendMode blend) {
133 std::find_if(solidBatches.begin(), solidBatches.end(), [&](const SolidBatch& sb) { return sb.blend == blend; });
159 for (std::size_t i = resolvedBatch.firstVertex; i < resolvedBatch.firstVertex + resolvedBatch.vertexCount;
172void Graphics::drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color& color,
175 std::find_if(solidBatches.begin(), solidBatches.end(), [&](const SolidBatch& sb) { return sb.blend == blend; });
214void Graphics::drawTexturedRectShaderUVRotated(Texture* texture, Shader* shader, float cx, float cy, float w, float h,
230void Graphics::drawTexturedRectShaderDepth(Texture* color, Texture* depth, Shader* shader, float x, float y, float w,
244void Graphics::drawTexturedRectShaderDepthMotion(Texture* color, Texture* depth, Texture* motion, Shader* shader,
261void Graphics::drawTexturedRectShader4(Texture* color, Texture* depth, Texture* motion, Texture* extra, Shader* shader,
279void Graphics::drawTexturedRectShader5(Texture* color, Texture* depth, Texture* motion, Texture* extra,
300void Graphics::drawTexturedRectLitUV(Texture* albedo, Texture* normal, float x, float y, float w, float h, float u0,
314void Graphics::drawTexturedRectLitUVRotated(Texture* albedo, Texture* normal, float cx, float cy, float w, float h,
321 if (litBatches.empty() || litBatches.back().albedo != albedo || litBatches.back().normal != normal ||
334void Graphics::flush2D(wgpu::RenderPassEncoder pass, int viewW, int viewH, WGPUTextureFormat format) {
377 auto solidPipe = [&](BlendMode mode) -> wgpu::RenderPipeline { return get2DColorPipeline(mode, offscreen); };
399 if (solidUploads[i].bytes > 0) drawSolid(uint32_t(i), 0, uint32_t(solidBatches[i].batch.vertices().size()));
413void Graphics::drawTexturedBatch(wgpu::RenderPassEncoder pass, TexturedBatch& tb, int viewW, int viewH,
451 queue.WriteBuffer(uboArena.buffer, pushOffset, tb.shader->pushConstantData(), Shader::kPushConstantBytes);
465 pipe = hdr ? gs->hdrOffscreenPipeline : (offscreen ? gs->offscreenPipeline : gs->swapchainPipeline);
591 if (offscreenTimestampSupported && offscreenTimestampQuerySet && offscreenTimestampResolveBuffer) {
593 const size_t index = (offscreenTimestampReadbackCursor + candidate) % offscreenTimestampReadbacks.size();
631 flushMesh3D(pass, canvas->isHDR() ? WGPUTextureFormat_RGBA16Float : WGPUTextureFormat_RGBA8Unorm, true);
632 flushPrimitive3D(pass, canvas->isHDR() ? WGPUTextureFormat_RGBA16Float : WGPUTextureFormat_RGBA8Unorm, 1);
636 encoder.CopyBufferToBuffer(offscreenTimestampResolveBuffer, 0, timestampSlot->buffer, 0, sizeof(uint64_t) * 2);
658 wgpuBufferMapAsync(timestampSlot->buffer.Get(), WGPUMapMode_Read, 0, sizeof(uint64_t) * 2, callback);
722void Graphics::setMesh3DPackedNormalMask(bool enabled) { mesh3dVirtualAtlas.z = enabled ? 1.f : 0.f; }
725void Graphics::setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY,
728 enabled ? glm::vec4(1.f, float(pageCountX), float(pageCountY), borderFraction) : glm::vec4(0.f);
730 mesh3dVirtualAtlas = enabled ? glm::vec4(float(atlasSlotsX), float(atlasSlotsY), packedNormalMask, 0.f)
751void Graphics::setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided, float alphaCutoff,
774void Graphics::setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle,
786void Graphics::setMesh3DSSAO(float intensity) { mesh3dSsaoIntensity = std::clamp(intensity, 0.f, 1.f); }
802 const uint64_t lightsBytes = std::max<uint64_t>(1, upload.lights.size()) * sizeof(ClusteredLightGpu);
803 const uint64_t tableBytes = std::max<uint64_t>(1, upload.clusterTable.size()) * sizeof(ClusterTableEntry);
804 const uint64_t indicesBytes = std::max<uint64_t>(1, upload.lightIndices.size()) * sizeof(uint32_t);
814 if (!upload.clusterTable.empty()) queue.WriteBuffer(st.table, 0, upload.clusterTable.data(), tableBytes);
815 if (!upload.lightIndices.empty()) queue.WriteBuffer(st.indices, 0, upload.lightIndices.data(), indicesBytes);
832void Graphics::setMesh3DReflectionProbes(const ReflectionProbeUpload& upload) { mesh3dReflectionProbes = upload; }
855void Graphics::drawMeshShadowAlpha(Mesh* mesh, const glm::mat4& lightMVP, Texture* albedo, bool doubleSided,
865 d.lodFade = glm::vec4(std::clamp(lodWeight, 0.f, 1.f), lodFadeReverse ? 1.f : 0.f, lodDither ? 1.f : 0.f, 0.f);
973 getRenderControl()->getGBuffer()->setTargets(gbufferWidth, gbufferHeight, &slot.depthColorTex, &slot.normalTex,
1001void Graphics::drawDecal(const glm::mat4& model, Texture* albedo, Texture* normal, Texture* params,
1014 draw.extraParams = glm::vec4(emissiveStrength, float(blendMode == 1), float(std::clamp(projectionMode, 0, 3)),
1073 ca.clearValue = {canvas->clearColor.r, canvas->clearColor.g, canvas->clearColor.b, canvas->clearColor.a};
1101void Graphics::clear(std::optional<Color> color, std::optional<int> /*stencil*/, std::optional<double> /*depth*/) {
Local-probe upload record kept off the high-fanout IGraphics3D header.
Accumulates solid / textured quads in logical (Y-down) coordinates. Used by RenderSystem; not a publi...
Definition Batcher.h:23
virtual Texture * getTexture()=0
Sampleable color buffer; screen Canvas returns nullptr.
Screen-space buffers for mid/post effects and Hybrid deferred lighting.
Definition GBuffer.h:28
void setTargets(int width, int height, Texture *depth, Texture *normal, Texture *albedo, Texture *hwDepth=nullptr, Texture *pbrParams=nullptr, Texture *emissive=nullptr)
Called by Graphics after a G-buffer pass (or clear).
Definition GBuffer.cpp:31
Definition Graphics.h:134
void ensureFileTexturesReady()
Finish CPU decode and GPU upload for outstanding newTextureFromFile results. @thread Game/render thre...
Definition GraphicsFileTextures.cpp:33
std::unique_ptr< RenderControl > renderControl_
Definition Graphics.h:2340
Mesh3DSceneColorCaptureStatus
Observable result of requesting a same-frame mesh SceneColor snapshot.
Definition Graphics.h:1227
@ ExplicitOverride
RenderControl * getRenderControl()
Shared compilable 3D render control (features → pass list + GBuffer). Owned by Graphics; valid for th...
Definition Graphics.cpp:279
Frame-local Skia-style recorder for 2D line primitives.
Definition PrimitiveDrawList.h:52
static constexpr uint32_t kPushConstantBytes
Definition Shader.h:45
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
bool supportsFiveTargetGBuffer() const
True when the granted device limit supports five RGBA8 GBuffer targets.
Definition Capabilities.h:55
void setMesh3DLodDither(float weight, bool reverse, bool enabled) override
Sets the mesh 3 d lod dither.
Definition GraphicsDraw.cpp:770
void setMesh3DEnv(Texture *cube, float intensity) override
Sets the mesh 3 d env.
Definition GraphicsDraw.cpp:822
void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) override
Sets the mesh 3 d light.
Definition GraphicsDraw.cpp:817
void setMesh3DPackedNormalMask(bool enabled) override
Sets the mesh 3 d packed normal mask.
Definition GraphicsDraw.cpp:722
void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload) override
Sets the mesh 3 d reflection probes.
Definition GraphicsDraw.cpp:832
void drawTexturedRectLitUVRotated(Texture *albedo, Texture *normal, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, const Color &color, BlendMode blend=BlendMode::Alpha) override
Draws textured rect lit uv rotated.
Definition GraphicsDraw.cpp:314
void flush2DToCanvas(OffscreenCanvas *canvas)
Flush accumulated 2D batches into an offscreen canvas target.
Definition GraphicsDraw.cpp:1060
Mesh3DSceneColorCaptureStatus captureMesh3DSceneColor() override
Capture mesh 3 d scene color.
Definition GraphicsDraw.cpp:736
void setMesh3DViewProj(const glm::mat4 &viewProj) override
Sets the mesh 3 d view proj.
Definition GraphicsDraw.cpp:667
void draw(eve::graphics::Graphics *gfx, const glm::mat4 &matrix) const override
Draws .
Definition GraphicsDraw.cpp:1091
void setMesh3DShadowReceive(bool receive) override
Sets the mesh 3 d shadow receive.
Definition GraphicsDraw.cpp:834
void clear(std::optional< Color > color, std::optional< int > stencil, std::optional< double > depth) override
Clears .
Definition GraphicsDraw.cpp:1101
void setMesh3DNormalTexture(Texture *normal) override
Sets the mesh 3 d normal texture.
Definition GraphicsDraw.cpp:721
void setMesh3DHeightTexture(Texture *height) override
Sets the mesh 3 d height texture.
Definition GraphicsDraw.cpp:723
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, BlendMode blend=BlendMode::Alpha) override
Draws textured rect lit uv.
Definition GraphicsDraw.cpp:300
void setMesh3DCameraPos(const glm::vec3 &eye) override
Sets the mesh 3 d camera pos.
Definition GraphicsDraw.cpp:821
void beginGBufferPass(int width, int height) override
Begins g buffer pass.
Definition GraphicsDraw.cpp:884
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, float motionX=0.f, float motionY=0.f, float roughness=0.45f, float metallic=0.f, float tintA=1.f) override
Draws mesh g buffer.
Definition GraphicsDraw.cpp:894
void setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY, float borderFraction) override
Sets the mesh 3 d virtual texture.
Definition GraphicsDraw.cpp:725
void setMesh3DEnvProbe(const glm::vec3 ¢er, const glm::vec3 &extent) override
Sets the mesh 3 d env probe.
Definition GraphicsDraw.cpp:827
void drawTexturedRectShader5(Texture *color, Texture *depth, Texture *motion, Texture *extra, Texture *specular, Shader *shader, float x, float y, float w, float h, const Color &tint) override
Draws textured rect shader 5.
Definition GraphicsDraw.cpp:279
void setMesh3DLighting(const Lighting3DPack &pack) override
Sets the mesh 3 d lighting.
Definition GraphicsDraw.cpp:773
void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader) override
Draws mesh shader.
Definition GraphicsDraw.cpp:685
void setMesh3DMaterial(float metallic, float roughness) override
Sets the mesh 3 d material.
Definition GraphicsDraw.cpp:747
void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color, BlendMode blend=BlendMode::Alpha) override
Draws solid rect rotated.
Definition GraphicsDraw.cpp:172
void setMesh3DSkinInfluenceLimit(SkinInfluenceLimit count) override
Sets the mesh 3 d skin influence limit.
Definition GraphicsDraw.cpp:835
void setLighting2D(const Lighting2DUBO &ubo) override
Sets the lighting 2 d.
Definition GraphicsDraw.cpp:329
void setMesh3DShadows(const ShadowUpload &upload) override
Sets the mesh 3 d shadows.
Definition GraphicsDraw.cpp:833
friend class OffscreenCanvas
Definition Graphics.h:790
Texture * newTexture(int width, int height, const uint8_t *rgba, bool repeatU=false, bool repeatV=false) override
Creates a texture. @ownership Caller deletes unless documented otherwise.
Definition GraphicsTextures.cpp:78
void drawTexturedRectShader4(Texture *color, Texture *depth, Texture *motion, Texture *extra, Shader *shader, float x, float y, float w, float h, const Color &tint) override
Draws textured rect shader 4.
Definition GraphicsDraw.cpp:261
void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint) override
Draws mesh.
Definition GraphicsDraw.cpp:681
void setMesh3DView(const glm::mat4 &view) override
Sets the mesh 3 d view.
Definition GraphicsDraw.cpp:668
void drawTexturedRect(Texture *texture, float x, float y, float w, float h, const Color &color) override
Draws textured rect.
Definition GraphicsDraw.cpp:184
void begin3DFrameToCanvas(Canvas *canvas) override
Begins 3 d frame to canvas.
Definition GraphicsDraw.cpp:571
void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color) override
Draws textured rect uv.
Definition GraphicsDraw.cpp:193
void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload) override
Sets the mesh 3 d clustered lighting.
Definition GraphicsDraw.cpp:780
void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f) override
Sets the mesh 3 d tex cell bomb.
Definition GraphicsDraw.cpp:760
void setMesh3DSceneColor(Texture *color) override
Sets the mesh 3 d scene color.
Definition GraphicsDraw.cpp:734
void beginDecalPass(int width, int height) override
Begins decal pass.
Definition GraphicsDraw.cpp:979
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
Draws textured rect shader uv rotated.
Definition GraphicsDraw.cpp:214
void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f) override
Sets the mesh 3 d parallax.
Definition GraphicsDraw.cpp:765
void drawTexturedRectShaderDepthMotion(Texture *color, Texture *depth, Texture *motion, Shader *shader, float x, float y, float w, float h, const Color &tint) override
Draws textured rect shader depth motion.
Definition GraphicsDraw.cpp:244
Texture * getSceneLinearDepthTexture() override
Return the active sampleable scene linear-depth texture when available. @ownership Borrowed from the ...
Definition GraphicsDraw.cpp:676
void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided=true) override
Draws mesh shadow.
Definition GraphicsDraw.cpp:845
void setMesh3DClusteredActive(bool active) override
Sets the mesh 3 d clustered active.
Definition GraphicsDraw.cpp:785
void drawPrimitiveCanvas(const PrimitiveCanvas2D &canvas) override
Draws primitive canvas.
Definition GraphicsDraw.cpp:142
void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo=nullptr, bool doubleSided=true, float lodWeight=1.f, bool lodFadeReverse=false, bool lodDither=false) override
Draws mesh shadow alpha.
Definition GraphicsDraw.cpp:855
void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage, float detail) override
Sets the cloud shadows.
Definition GraphicsDraw.cpp:774
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, float motionX=0.f, float motionY=0.f, float roughness=0.45f, float metallic=0.f, float tintA=1.f) override
Draws mesh g buffer alpha.
Definition GraphicsDraw.cpp:930
void setMesh3DClip(float nearZ, float farZ) override
Sets the mesh 3 d clip.
Definition GraphicsDraw.cpp:669
void drawDecal(const glm::mat4 &model, Texture *albedo, Texture *normal, Texture *params, const float uvRect[4], float fade, float normalStrength, float roughnessStrength, float metalStrength, float emissiveStrength, int blendMode=0, int projectionMode=0, float blendSharpness=4.f, float parallaxScale=0.f, float parallaxMinLayers=8.f, float parallaxMaxLayers=24.f, float edgeFadeWidth=0.06f) override
Draws decal.
Definition GraphicsDraw.cpp:1001
void setDecalCamera(const glm::mat4 &viewProj, float nearZ, float farZ) override
Sets the decal camera.
Definition GraphicsDraw.cpp:995
void setMesh3DSceneDepth(Texture *depth) override
Sets the mesh 3 d scene depth.
Definition GraphicsDraw.cpp:733
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
Draws textured rect shader uv.
Definition GraphicsDraw.cpp:198
Canvas * newHDRCanvas(int width, int height) override
Creates a hdr canvas. @ownership Caller deletes unless documented otherwise.
Definition GraphicsDraw.cpp:1044
void drawSolidRect(float x, float y, float w, float h, const Color &color, BlendMode blend=BlendMode::Alpha) override
Draws solid rect.
Definition GraphicsDraw.cpp:131
Canvas * newCanvas(int width, int height) override
Creates a canvas. @ownership Caller deletes unless documented otherwise.
Definition GraphicsDraw.cpp:1038
void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w, float h, const Color &color) override
Draws textured rect shader.
Definition GraphicsDraw.cpp:188
void drawTexturedRectShaderDepth(Texture *color, Texture *depth, Shader *shader, float x, float y, float w, float h, const Color &tint) override
Draws textured rect shader depth.
Definition GraphicsDraw.cpp:230
void setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided, float alphaCutoff, const std::string &alphaTechnique="cutoff") override
Sets the mesh 3 d surface.
Definition GraphicsDraw.cpp:751
Texture * getSceneColorTexture() override
Returns the scene color texture.
Definition GraphicsDraw.cpp:674
Offscreen render target (RGBA8Unorm color, optional Depth32Float). 2D batches are flushed into the ca...
Definition Canvas.h:17
WGPUStringView sv(const char *s)
Build a WGPUStringView from a C string (null-safe, length auto-computed).
Definition wgpu_types.h:20
ResolvedPrimitiveTriangles resolvePrimitiveStrokes2D(const PrimitiveCanvas2D &canvas, glm::ivec2 viewport)
Resolves 2D stroke segment bodies into clip-space triangles.
Definition PrimitiveTessellator.cpp:381
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
SkinInfluenceLimit
Number of strongest vertex influences retained by GPU skinning.
Definition IGraphics3D.h:20
@ Premultiplied
@ Additive
@ Alpha
@ Multiply
@ Opaque
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Definition ClusteredLight.h:33
std::vector< ClusteredLightGpu > lights
Definition ClusteredLight.h:42
std::vector< uint32_t > lightIndices
Definition ClusteredLight.h:44
std::vector< ClusterTableEntry > clusterTable
Definition ClusteredLight.h:43
Resolved triangle vertex consumed by primitive GPU backends.
Definition PrimitiveTessellator.h:14
ReflectionProbeUpload public API.
Definition ReflectionProbeUpload.h:18
One contiguous 2D blend/order batch in the resolved vertex stream.
Definition PrimitiveTessellator.h:32