载入中...
搜索中...
未找到
Graphics.h
浏览该文件的文档.
1#pragma once
3#include "common/Export.h"
4
5
6#include <cstdint>
7// Incomplete glm types cover const-ref / pointer / reference-return APIs.
8// Particle spawn layouts, entity-ID draws and complete vec3 color-grade records
9// live in GpuParticles.h / GraphicsVisibility.h / GraphicsRgb.h.
10#include <glm/fwd.hpp>
11#include <memory>
12#include <span>
13#include <string>
14#include <vector>
15#include "common/Capability.h"
17#include "common/Module.h"
18#include "common/Result.h"
20#include "graphics/BlendMode.h"
21#include "graphics/Canvas.h"
22#include "graphics/Color.h"
29#include "graphics/IPostFX.h"
34
35struct aiMesh;
36
37namespace eve {
38class Subscription;
39class FrameCaptureStore;
40}
41
42namespace eve::font {
43class FontData;
44}
45
46namespace eve::graphics {
47struct PbrSurface;
48struct ShaderResourceInputs;
49
50
51class AmbientOcclusion;
52class IRayTracing;
53class AntiAliasing;
54class Bloom;
55class ContactShadow;
56class DepthOfField;
57class Exposure;
58class DepthPyramid;
59class Camera3D;
60class Drawable;
61class GBuffer;
62class GlobalIllumination;
63class GrassField;
64namespace hair {
65class GroomInstance;
66}
67class Material;
68class Mesh;
69class PrimitiveScene;
70
77 int x = 0;
78 int y = 0;
79 int width = 0;
80 int height = 0;
81 std::span<const std::uint8_t> rgba;
82 std::size_t bytesPerRow = 0;
83};
84
93 std::uint32_t vertexCount = 0;
94 std::uint32_t indexCount = 0;
95 std::uint32_t vertexStride = 0;
96 std::uint32_t indexElementSize = 0;
97};
98class Font;
99class Outline;
100class Quad;
101class RenderControl;
102class Renderable2D;
103class AlphaMask;
104class DepthOfField;
105class MapFog;
107class Shader;
109class Texture;
110class Volumetric;
111class Water;
112class Waterfall;
116struct Lighting2DUBO;
117struct Lighting3DPack;
118struct ShadowUpload;
119struct TextureCreateInfo;
120struct TextureSampler;
121class IGpuParticles;
123
125 public Canvas,
126 public IWindowSurfaceHost,
127 public IGraphics2D,
128 public IGraphics3D,
129 public ICanvasFactory,
130 public ICanvasTarget,
131 public IResourceFactory,
132 public ISolidRectRenderer,
133 public IPostFX,
134 public IFramePresentation {
135public:
138 Graphics();
146 [[nodiscard]] eve::OptionalRef<IRayTracing> rayTracingService() const noexcept;
147
149 ~Graphics() override;
150
153 FrameCaptureStore &frameCaptures();
154
158 virtual void reset();
159
161 virtual void clearScreen();
163 virtual void setBackgroundColorRGBA(float r, float g, float b, float a = 1.f);
165 virtual void drawSolidRectRGBA(float x, float y, float w, float h, float r, float g, float b, float a = 1.f);
167 virtual void drawTexturedRectRGBA(Texture *texture, float x, float y, float w, float h, float r, float g, float b,
168 float a = 1.f);
170 virtual void drawTexturedRectRotatedRGBA(Texture* texture, float cx, float cy, float w, float h, float degrees,
171 float r, float g, float b, float a = 1.f);
173 virtual void drawSolidRect(float x, float y, float w, float h, float r, float g, float b, float a = 1.f);
175 virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h, float r, float g, float b,
176 float a = 1.f);
178 void renderSprites();
180 Renderable2D *newSprite2D();
187 Texture *newTextureFromImageData(image::ImageData *data, bool repeatU = false,
188 bool repeatV = false);
190 Texture *newTextureFromImageData(image::ImageData *data, const TextureCreateInfo &info);
191
200 [[nodiscard]] eve::Result<void> updateTextureFromImageData(Texture* texture, image::ImageData* data);
201
206 Texture* newTextureWithSampler(image::ImageData* data, bool repeatU, bool repeatV, bool generateMipmaps,
207 float maxAnisotropy, const std::string& filter, const std::string& mipmap,
208 float lodBias = 0.f);
209
218 virtual void setTextureSampler(Texture *texture, const std::string &filter, const std::string &mipmap,
219 float maxAnisotropy, float lodBias);
220
222 virtual void present() = 0;
223
225 virtual std::string getBackendName() const = 0;
226
236 virtual bool supportsRuntimeGlslCompilation() const { return false; }
246 [[nodiscard]] std::weak_ptr<const void> resourceLifetime() const;
252 [[nodiscard]] Result<eve::Subscription> onResourcesRetiring(std::function<void()> callback) const;
253
254
260 virtual bool supportsGBufferPost() const { return true; }
261
262 // ---- GPU-driven rendering (stage 1): capability-gated seam ----
263 // Backends without the GPU-driven path (WebGPU, software) return false and
264 // RenderSystem3D falls back to the legacy per-draw path.
265
267 virtual bool supportsDeferredLighting() const { return false; }
268
274 virtual void drawDeferredLighting() {}
275
277 virtual bool supportsGpuDriven3D() const { return false; }
278
284 virtual bool supportsRayTracing() const { return false; }
285
287 virtual RayTracingCaps rayTracingCaps() const { return {}; }
288
290 virtual bool gpuDrivenEnabled() const { return false; }
291
293 virtual void gpuDrivenSetEnabled(bool enabled) { (void)enabled; }
294
296 virtual uint32_t gpuDrivenMeshRecord(Mesh* mesh) {
297 (void)mesh;
299 }
300
303 (void)material;
305 }
306
315 (void)material;
317 return Result<void>::failure(Diagnostic::error(
318 DiagnosticCode::Unsupported, "GPU-driven material records are unavailable on this backend"));
319 }
320
327 (void)material;
328 return false;
329 }
330
332 virtual uint32_t gpuDrivenReflectionProbeSlot(Texture *cubemap) {
333 (void)cubemap;
335 }
336
337 // ---- GPU-resident 2D particles (see GpuParticles.h / IGpuParticles) ----
338
344 [[nodiscard]] virtual IGpuParticles* gpuParticles() noexcept { return nullptr; }
345
352 virtual bool gpuDrivenSubmitOpaque(const GpuInstance *instances, uint32_t instanceCount) {
353 (void)instances;
354 (void)instanceCount;
355 return false;
356 }
357
366 (void)batch;
367 return GpuResidentSubmitStatus::Unsupported;
368 }
369
370 // ---- GPU-driven rendering (stage 2): GPU cull seam ----
371 // Backends without the compute cull chain return false / no-op; the
372 // renderer then falls back to gpuDrivenSubmitOpaque (stage 1) or legacy.
373
375 virtual bool gpuDrivenCullEnabled() const { return false; }
376
378 virtual bool gpuDrivenScenePassPending() const { return false; }
379
381 virtual bool gpuDrivenCullBegin(const GpuInstance *instances, uint32_t instanceCount) {
382 (void)instances;
383 (void)instanceCount;
384 return false;
385 }
386
388 virtual void gpuDrivenCullEmit(const glm::mat4& viewProj, const glm::vec3& eye, float fovYDeg, float nearZ,
389 float farZ) {
390 (void)viewProj;
391 (void)eye;
392 (void)fovYDeg;
393 (void)nearZ;
394 (void)farZ;
395 }
396
398 virtual void gpuDrivenOpenScenePass() {}
399
401 virtual void gpuDrivenDrawOpaque() {}
402
403 // ---- GPU-driven rendering (stage 3): visibility buffer + resolve seam ----
404 // Backends without the resolve path return false / no-op; the renderer
405 // keeps using gpuDrivenDrawOpaque (forward shading).
406
408 virtual bool gpuDrivenResolveWanted() const { return false; }
409
411 virtual void gpuDrivenRecordVisPass() {}
412
414 virtual void gpuDrivenResolve() {}
415
416 // ---- GPU-driven rendering (stage 3): virtual-geometry seam ----
417 // Backends without VG support return kInvalidGpuDrivenSlot / false; the
418 // renderer then draws the mesh through the normal GPU-driven path.
419
421 virtual std::uint32_t gpuDrivenVgUpload(const GpuVgAssetUpload &asset) {
422 (void)asset;
424 }
425
427 virtual std::uint32_t gpuDrivenVgAssetId(Mesh *mesh) const {
428 (void)mesh;
430 }
431
433 virtual bool gpuDrivenVgAttachToMesh(Mesh *mesh, std::uint32_t vgAssetId) {
434 (void)mesh;
435 (void)vgAssetId;
436 return false;
437 }
438
445 virtual bool gpuDrivenVgSetInstance(std::uint32_t vgAssetId, const glm::mat4 &model,
446 std::uint32_t materialId) {
447 (void)vgAssetId;
448 (void)model;
449 (void)materialId;
450 return false;
451 }
452
454 virtual void gpuDrivenVgComputeSection(const glm::mat4& viewProj, const glm::vec3& eye, float fovYDeg, float nearZ,
455 float farZ) {
456 (void)viewProj;
457 (void)eye;
458 (void)fovYDeg;
459 (void)nearZ;
460 (void)farZ;
461 }
462
467 virtual void initWithWindow(void *nativeWindow) = 0;
468
478 virtual void initHeadless(int width, int height);
479
481 virtual bool isHeadless() const { return false; }
482
486 virtual void setViewportSize(int width, int height, int pixelwidth, int pixelheight) = 0;
487
489 int getWidth() const { return width; }
491 int getHeight() const { return height; }
493 int getPixelWidth() const { return pixelWidth; }
495 int getPixelHeight() const { return pixelHeight; }
496
498 double getCurrentDPIScale() const { return (width > 0) ? double(pixelWidth) / double(width) : 1.0; }
500 double getScreenDPIScale() const { return getCurrentDPIScale(); }
501
508 [[nodiscard]] std::shared_ptr<PrimitiveScene> getPrimitiveScene() const noexcept { return primitiveScene_; }
509
511 virtual void drawSolidRect(float x, float y, float w, float h, const Color &color,
512 BlendMode blend = BlendMode::Alpha) = 0;
513
515 virtual void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color& color,
516 BlendMode blend = BlendMode::Alpha) = 0;
517
522 virtual Texture *newTexture(int width, int height, const uint8_t *rgba, bool repeatU = false,
523 bool repeatV = false) = 0;
524
529 virtual Texture* newTexture(int width, int height, const uint8_t* rgba, const TextureCreateInfo& info) = 0;
530
535 virtual Texture *newCubemap(int faceSize, const uint8_t *rgbaFaces) = 0;
536
541 virtual Texture *newCubemap(int faceSize, const uint8_t *rgbaFaces,
542 const TextureCreateInfo &info) = 0;
543
549 virtual Texture *newHDRCubemap(int faceSize) {
550 (void)faceSize;
551 return nullptr;
552 }
553
559 virtual bool copyHDRCanvasToCubemapFace(Canvas *source, Texture *cubemap, int face) {
560 (void)source;
561 (void)cubemap;
562 (void)face;
563 return false;
564 }
565
577 virtual bool copyHDRCanvasesToCubemap(Canvas* const* sources, int faceCount, Texture* cubemap) {
578 if (!sources || faceCount < 1 || faceCount > 6) return false;
579 for (int face = 0; face < faceCount; ++face)
580 if (!copyHDRCanvasToCubemapFace(sources[face], cubemap, face)) return false;
581 return true;
582 }
583
588 virtual bool filterHDRReflectionCubemap(Texture *cubemap, int sampleCount = 64) {
589 (void)cubemap;
590 (void)sampleCount;
591 return false;
592 }
593
596
599
610 virtual bool updateTexture(Texture *texture, int width, int height, const uint8_t *rgba) = 0;
611
632 int width, int height) {
633 (void)texture;
634 (void)source;
635 (void)width;
636 (void)height;
639 "Resident texture upload is unavailable",
640 "graphics.updateTextureFromResidentRgba8"));
641 }
642
657 [[nodiscard]] virtual eve::Result<void> updateTextureRegion(Texture* texture, int x, int y, int width, int height,
658 std::span<const std::uint8_t> rgba,
659 std::size_t bytesPerRow = 0) = 0;
660
671 std::span<const TextureRegionUpload> regions) = 0;
672
680
682 virtual float getMaxAnisotropy() const = 0;
683
690 Texture *newTextureFromFile(const std::string &filename) override;
699 [[nodiscard]] ResultRef<Texture> loadTexture(const std::string &filename) override;
704 Texture *newTextureFromFileRepeated(const std::string &filename, bool repeatU, bool repeatV);
705
711 void ensureFileTexturesReady();
712
714 virtual bool reloadTextureFromFile(const std::string &filename) = 0;
715
733 (void)texture;
734 return false;
735 }
736
740 virtual void drawTexturedRect(Texture* texture, float x, float y, float w, float h, const Color& color) = 0;
741
743 virtual void drawTexturedRectShader(Texture* texture, Shader* shader, float x, float y, float w, float h,
744 const Color& color) = 0;
745
747 virtual void drawTexturedRectUV(Texture* texture, float x, float y, float w, float h, float u0, float v0, float u1,
748 float v1, const Color& color) = 0;
749
751 virtual void drawTexturedRectShaderUV(Texture* texture, Shader* shader, float x, float y, float w, float h,
752 float u0, float v0, float u1, float v1, const Color& color,
753 bool rotatedUV = false, BlendMode blend = BlendMode::Alpha) = 0;
754
759 virtual void drawTexturedRectShaderUVRotated(Texture* texture, Shader* shader, float cx, float cy, float w, float h,
760 float degrees, float u0, float v0, float u1, float v1,
761 const Color &color, bool rotatedUV = false,
762 BlendMode blend = BlendMode::Alpha) = 0;
763
768 virtual void drawTexturedRectShaderDepth(Texture* color, Texture* depth, Shader* shader, float x, float y, float w,
769 float h, const Color& tint) = 0;
770
773 float x, float y, float w, float h, const Color& tint) = 0;
774
777 Shader* shader, float x, float y, float w, float h, const Color& tint) = 0;
778
781 Texture* specular, Shader* shader, float x, float y, float w, float h,
782 const Color &tint) = 0;
783
792 enum class SceneColorDistortionStatus { Queued, Unavailable };
793
796 float w, float h, float degrees, float u0,
797 float v0, float u1, float v1,
798 float strengthPixels, float opacity,
799 bool rotatedUV = false) {
800 return SceneColorDistortionStatus::Unavailable;
801 }
802
807 virtual void drawTexturedRectLitUV(Texture *albedo, Texture *normal, float x, float y, float w, float h, float u0,
808 float v0, float u1, float v1, const Color &color,
809 BlendMode blend = BlendMode::Alpha) = 0;
810
816 virtual void drawTexturedRectLitUVRotated(Texture *albedo, Texture *normal, float cx, float cy, float w, float h,
817 float degrees, float u0, float v0, float u1, float v1, const Color &color,
818 BlendMode blend = BlendMode::Alpha) = 0;
819
821 virtual void setLighting2D(const Lighting2DUBO &ubo) = 0;
822
824 Quad *newQuad(int x, int y, int w, int h);
825
829 virtual Mesh *newMeshFromAssimp(const ::aiMesh &mesh) = 0;
830
837 virtual Mesh* newMeshFromAssimp(const ::aiMesh& mesh, const glm::mat4& worldTransform) = 0;
838
847 virtual Mesh *newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST,
848 int vertexCount, const uint32_t *indices, int indexCount) = 0;
850 virtual Mesh *newMeshFromArraysColored(const float *posXYZ, const float *nrmXYZ, const float *uvST,
851 const float *colorRGBA, int vertexCount,
852 const uint32_t *indices, int indexCount) = 0;
853
864 (void)mesh;
866 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "mesh backend descriptor is unavailable", {}, {},
867 "graphics.mesh.describe"));
868 }
869
883 virtual bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ,
884 const float *uvST, int vertexCount, const uint32_t *indices,
885 int indexCount) = 0;
886
890 virtual bool setMeshSkinningData(Mesh *mesh, const uint16_t *joints4, const float *weights4,
891 int vertexCount) {
892 (void)mesh;
893 (void)joints4;
894 (void)weights4;
895 (void)vertexCount;
896 return false;
897 }
898
903 virtual bool bakeMeshMorph(Mesh *mesh) = 0;
904
909 virtual Mesh *newMeshSphere(int slices = 32, int stacks = 16) = 0;
910
916 virtual Mesh *newMeshCylinder(int slices = 32, int stacks = 1, bool caps = true) = 0;
917
922 Mesh *newMeshCube(float size = 1.f);
923
935 virtual bool releaseMesh(Mesh *mesh) {
936 (void)mesh;
937 return false;
938 }
939
941 virtual void render3D();
942
947 [[nodiscard]] std::uint64_t mesh3dDrawEpoch() const noexcept { return mesh3dDrawEpoch_; }
953 virtual void renderScene3DToCanvas(Canvas *canvas, Camera3D *camera);
961 void renderScene3DWithShadowsToCanvas(Canvas *canvas, Camera3D *camera);
963 virtual void setDirectionalLight(float dx, float dy, float dz, float r = 1.f, float g = 1.f, float b = 1.f);
964
971 virtual void drawScene3DRGBA(float x, float y, float w, float h, float r = 1.f, float g = 1.f, float b = 1.f,
972 float a = 1.f);
974 void drawScene3D(float x, float y, float w, float h) { drawScene3DRGBA(x, y, w, h, 1.f, 1.f, 1.f, 1.f); }
975
977 virtual void drawCanvasRGBA(Canvas *canvas, float x, float y, float w, float h, float r = 1.f, float g = 1.f,
978 float b = 1.f, float a = 1.f);
980 void drawCanvas(Canvas *canvas, float x, float y, float w, float h) {
981 drawCanvasRGBA(canvas, x, y, w, h, 1.f, 1.f, 1.f, 1.f);
982 }
983
988 virtual void pushValidationScope() = 0;
990 virtual void popValidationScope() = 0;
991
996 Material *newMaterial();
997
1002 RenderControl *getRenderControl();
1003
1009 virtual void beginGBufferPass(int width, int height) = 0;
1015 virtual void drawMeshGBuffer(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ,
1016 Texture *albedo = nullptr, float tintR = 1.f, float tintG = 1.f, float tintB = 1.f,
1017 float motionX = 0.f, float motionY = 0.f, float roughness = 0.45f,
1018 float metallic = 0.f, float tintA = 1.f) = 0;
1027 virtual void drawMeshGBufferAlpha(Mesh *mesh, const glm::mat4 &mvp, const glm::mat4 &model, float nearZ, float farZ,
1028 Texture *albedo = nullptr, float tintR = 1.f, float tintG = 1.f,
1029 float tintB = 1.f, float motionX = 0.f, float motionY = 0.f,
1030 float roughness = 0.45f, float metallic = 0.f, float tintA = 1.f) = 0;
1032 virtual void endGBufferPass() = 0;
1033
1041 virtual void begin3DFrame() = 0;
1042
1050 virtual void begin3DFrameToCanvas(Canvas *canvas) = 0;
1052 virtual void end3DFrameToCanvas() = 0;
1053
1058 virtual float getLastOffscreen3DGpuDurationMs() const { return 0.f; }
1059
1063 virtual void setMesh3DViewProj(const glm::mat4 &viewProj) = 0;
1064
1066 virtual void setMesh3DView(const glm::mat4 &view) = 0;
1067
1069 virtual void setMesh3DClip(float nearZ, float farZ) = 0;
1070
1075 virtual Texture *getSceneColorTexture() { return nullptr; }
1077 virtual Texture* getSceneLinearDepthTexture() { return nullptr; }
1078
1085 [[nodiscard]] virtual IVisibilityCapture* visibilityCapture() noexcept { return nullptr; }
1086
1094 virtual image::ImageData *readGBufferToImageData(const std::string &attachment) {
1095 (void)attachment;
1096 return nullptr;
1097 }
1104 virtual image::ImageData *readDecalLayerToImageData(const std::string &attachment) {
1105 (void)attachment;
1106 return nullptr;
1107 }
1108
1120 (void)mesh;
1121 (void)source;
1122 return Result<void>::failure(Diagnostic::error(
1123 DiagnosticCode::Unsupported, "Resident mesh vertices require Vulkan", "graphics.residentMesh"));
1124 }
1125
1127 virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint) = 0;
1128
1130 virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint,
1131 Shader *shader) = 0;
1132
1136 [[nodiscard]] virtual bool supportsMeshInstancing() const { return false; }
1137
1151 [[nodiscard]] virtual Result<void> drawMeshInstances(Mesh &mesh, std::span<const glm::mat4> models,
1153 (void)mesh;
1154 (void)models;
1155 (void)texture;
1156 (void)tint;
1157 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,
1158 "Ordinary mesh instancing is unavailable on this backend",
1159 "graphics.meshInstances"));
1160 }
1161
1175 [[nodiscard]] virtual Result<void> drawMeshShaderInstances(Mesh &mesh, Shader &shader, const glm::mat4 &model,
1176 const Color &tint, std::uint32_t first,
1177 std::uint32_t count) {
1178 (void)mesh;
1179 (void)shader;
1180 (void)model;
1181 (void)tint;
1182 (void)first;
1183 (void)count;
1185 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Unsupported,
1186 "Custom mesh instancing is unavailable on this backend",
1187 "graphics.instances"));
1188 }
1189
1192
1194 virtual void setMesh3DPackedNormalMask(bool enabled) = 0;
1195
1198
1205 virtual void setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY,
1206 float borderFraction) = 0;
1207
1214
1225
1227 enum class Mesh3DSceneColorCaptureStatus { ExplicitOverride, Scheduled, Captured, HistoryReuse, Unavailable };
1228
1243 return Mesh3DSceneColorCaptureStatus::HistoryReuse;
1244 }
1245
1247 virtual void setMesh3DMaterial(float metallic, float roughness) = 0;
1253 [[nodiscard]] virtual Result<void> setMesh3DPbrSurface(const PbrSurface* surface) {
1254 if (!surface) return Result<void>::success();
1256 return Result<void>::failure(Diagnostic::error(
1257 DiagnosticCode::Unsupported, "extended PBR material rendering is unavailable on this backend"));
1258 }
1259
1261 virtual void setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided,
1262 float alphaCutoff, const std::string& alphaTechnique = "cutoff") = 0;
1263
1269 virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount = 1.f) = 0;
1270
1276 virtual void setMesh3DParallax(float scale, float minLayers = 8.f, float maxLayers = 32.f) = 0;
1277
1279 virtual void setMesh3DLodDither(float weight, bool reverse, bool enabled) = 0;
1280
1282 virtual void setMesh3DLighting(const Lighting3DPack &pack) = 0;
1283
1289 virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle,
1290 float coverage, float detail) = 0;
1291
1297
1303 virtual void setMesh3DClusteredActive(bool active) = 0;
1304
1309 virtual void setMesh3DSSAO(float intensity) = 0;
1310
1312 virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color) = 0;
1313
1315 virtual void setMesh3DCameraPos(const glm::vec3 &eye) = 0;
1316
1325 virtual void drawVoxelFaceInstances(const uint32_t* packed, int count, float originX, float originY, float originZ,
1326 const std::string& faceDir, Texture* atlas, int tilesPerRow = 16,
1327 const uint32_t *ao = nullptr) = 0;
1328
1335 virtual bool supportsDecal() const { return true; }
1336
1343 virtual void beginDecalPass(int width, int height) = 0;
1344
1347 virtual void setDecalCamera(const glm::mat4 &viewProj, float nearZ, float farZ) = 0;
1348
1364 virtual void drawDecal(const glm::mat4 &model, Texture *albedo, Texture *normal,
1365 Texture *params, const float uvRect[4], float fade,
1366 float normalStrength, float roughnessStrength, float metalStrength,
1367 float emissiveStrength, int blendMode = 0, int projectionMode = 0,
1368 float blendSharpness = 4.f, float parallaxScale = 0.f,
1369 float parallaxMinLayers = 8.f, float parallaxMaxLayers = 24.f,
1370 float edgeFadeWidth = 0.06f) = 0;
1372 virtual void endDecalPass() = 0;
1373
1379 virtual void setMesh3DEnv(Texture *cube, float intensity) = 0;
1381 virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent) = 0;
1383 virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload) = 0;
1386 enum class SceneToneMapping { None, Aces, Filmic };
1388 enum class DisplayOutputMode { Sdr, Auto, Hdr10, ScRgb };
1390 enum class DisplayColorSpace { Sdr, ScRgb, Hdr10 };
1393 bool sdr = true;
1394 bool hdr10 = false;
1395 bool scRgb = false;
1396 };
1406 [[nodiscard]] virtual Result<void> setSceneToneMapping(SceneToneMapping mode);
1408 virtual SceneToneMapping getSceneToneMapping() const { return SceneToneMapping::Aces; }
1418 [[nodiscard]] virtual Result<void> setDisplayOutputMode(DisplayOutputMode mode);
1420 virtual DisplayOutputMode getDisplayOutputMode() const;
1427 [[nodiscard]] virtual Result<void> setDisplayHdrCalibration(float paperWhiteNits, float peakNits);
1429 virtual float getDisplayPaperWhiteNits() const;
1431 virtual float getDisplayPeakNits() const;
1433 virtual DisplayColorSpace getActiveDisplayColorSpace() const;
1435 virtual bool isDisplayHdrActive() const;
1441 [[nodiscard]] virtual Result<DisplayOutputSupport> queryDisplayOutputSupport() const;
1446 [[nodiscard]] virtual Result<void> setScenePhotographicVignette(float intensity);
1448 virtual float getScenePhotographicVignette() const { return 0; }
1450 virtual void setSceneExposure(float exposure) = 0;
1452 virtual float getSceneExposure() const = 0;
1454 virtual void setSceneColorFilter(const RgbF& color) = 0;
1456 [[nodiscard]] virtual RgbF getSceneColorFilter() const = 0;
1458 virtual void setSceneLiftGammaGain(const RgbF& lift, const RgbF& inverseGamma, const RgbF& gain) = 0;
1460 [[nodiscard]] virtual RgbF getSceneLift() const = 0;
1462 [[nodiscard]] virtual RgbF getSceneInverseGamma() const = 0;
1464 [[nodiscard]] virtual RgbF getSceneGain() const = 0;
1466 virtual void setSceneTransitionFx(float vignette, float vignetteSmoothness, float lensDistortion,
1467 float lensScale) = 0;
1469 virtual float getSceneTransitionVignette() const = 0;
1471 virtual float getSceneTransitionVignetteSmoothness() const = 0;
1473 virtual float getSceneTransitionLensDistortion() const = 0;
1475 virtual float getSceneTransitionLensScale() const = 0;
1477 virtual void setSceneAutoExposure(bool enabled, float minEV, float maxEV) = 0;
1479 virtual bool getSceneAutoExposure() const = 0;
1481 virtual float getSceneAutoExposureMinEV() const = 0;
1483 virtual float getSceneAutoExposureMaxEV() const = 0;
1485 virtual void setSceneBloom(float intensity, float threshold) = 0;
1487 virtual float getSceneBloomIntensity() const = 0;
1489 virtual float getSceneBloomThreshold() const = 0;
1498 virtual void setSceneDepthOfField(float focusDistance, float maxBlurPx, float focusRange,
1499 float nearZ, float farZ) = 0;
1501 virtual float getSceneDofFocusDistance() const = 0;
1503 virtual float getSceneDofMaxBlur() const = 0;
1505 virtual float getSceneDofFocusRange() const = 0;
1507 virtual float getSceneDofNearZ() const = 0;
1509 virtual float getSceneDofFarZ() const = 0;
1510
1512 virtual void setMesh3DShadows(const ShadowUpload &upload) = 0;
1513
1515 virtual void setMesh3DShadowReceive(bool receive) = 0;
1516
1523
1529 virtual void beginShadowPass(int cascadeIndex) = 0;
1532 virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided = true) = 0;
1540 virtual void drawMeshShadowAlpha(Mesh* mesh, const glm::mat4& lightMVP, Texture* albedo = nullptr,
1541 bool doubleSided = true, float lodWeight = 1.f,
1542 bool lodFadeReverse = false, bool lodDither = false) = 0;
1544 virtual void endShadowPass() = 0;
1545
1548 bool v = frameHad3D;
1549 return v;
1550 }
1552 bool had3DThisFrame() const { return frameHad3D; }
1553
1555 Color getBackgroundColor() const { return backgroundColor; }
1557 void setBackgroundColor(const Color &c) { backgroundColor = c; }
1558
1563 virtual void setScreenReadbackEnabled(bool enabled) { screenReadbackEnabled = enabled; }
1565 bool isScreenReadbackEnabled() const { return screenReadbackEnabled; }
1566
1571 bool saveFramePng(const std::string &path);
1572
1578 virtual bool beginFrameReadback(const std::string &path) {
1579 (void)path;
1580 return false;
1581 }
1583 virtual int frameReadbackStatus() const { return 0; }
1584
1589 virtual void setVSync(bool enabled) { vsyncEnabled = enabled; }
1591 bool isVSync() const { return vsyncEnabled; }
1593 void setVSyncCount(int count) override { presentationVSyncCount_=count;setVSync(count!=0); }
1595 int getVSyncCount() const noexcept override{return presentationVSyncCount_;}
1596
1602 virtual void setMsaaSamples(int samples) { msaaSamples = samples > 0 ? samples : 0; }
1604 virtual int getMsaaSamples() const { return msaaSamples; }
1605
1607 void setActive(bool active) override {
1608 // Only dirty on inactive→active. Cocoa can re-post SHOWN/RESTORED during
1609 // resize event pumps; marking dirty every time recreates the swapchain
1610 // every frame (MoltenVK Suboptimal thrash) and leaves SpatialAA on its
1611 // first-frame clear forever.
1612 if (active && !graphicsActive) markSwapchainDirty();
1613 graphicsActive = active;
1614 }
1616 bool isActive() const { return graphicsActive; }
1617
1619 virtual void markSwapchainDirty() {}
1620
1626 void requestSurfaceRecreate() override {}
1627
1642 for (auto &cb : windowDestroyedCallbacks_) cb.first(cb.second);
1643 windowDestroyedCallbacks_.clear();
1645 clearPresentOverlay();
1646 }
1647
1650 presentOverlayFn_ = nullptr;
1651 presentOverlayUser_ = nullptr;
1652 }
1653
1659 using WindowDestroyedCallback = void (*)(void *userdata);
1662 windowDestroyedCallbacks_.emplace_back(cb, userdata);
1663 }
1664
1671 using PresentOverlayFn = bool (*)(void *userdata, void *commandBuffer);
1673 void setPresentOverlay(PresentOverlayFn fn, void *userdata) {
1674 presentOverlayFn_ = fn;
1675 presentOverlayUser_ = userdata;
1676 }
1678 PresentOverlayFn getPresentOverlay() const { return presentOverlayFn_; }
1680 void *getPresentOverlayUser() const { return presentOverlayUser_; }
1681
1690 Font* newFont(font::FontData* data);
1692 Font* newFont(font::FontData* data, std::string charset) override;
1693
1695 virtual void setFont(Font *font) { currentFont = font; }
1697 Font *getFont() const { return currentFont; }
1698
1709 virtual void print(const std::string& text, float x, float y, const Color& color = Color(1.f, 1.f, 1.f, 1.f),
1710 float scale = 1.f);
1711
1724 virtual void drawText(Font *font, const std::string &text, float x, float y,
1725 const Color &color = Color(1.f, 1.f, 1.f, 1.f), float scale = 1.f);
1726
1742 void drawTextRGBA(Font* font, const std::string& text, float x, float y, float r, float g, float b, float a,
1743 float scale = 1.f) {
1745 drawText(font, text, x, y, Color(r, g, b, a), scale);
1746 }
1747
1761 void printRGBA(const std::string& text, float x, float y, float r, float g, float b, float a, float scale = 1.f) {
1763 print(text, x, y, Color(r, g, b, a), scale);
1764 }
1765
1767 virtual void setShader(Shader *shader);
1769 virtual void setShader();
1770
1772 Shader *getShader() const { return currentShader; }
1773
1778 virtual Shader *newShaderFromSpv(const std::vector<uint32_t> &vertSpv,
1779 const std::vector<uint32_t> &fragSpv) = 0;
1780
1782 virtual Shader *newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath) = 0;
1784 Shader *newShaderFromSpvFile(const std::string &fragPath) {
1786 return newShaderFromSpvFile(std::string(), fragPath);
1787 }
1788
1794 virtual Shader *newShader(const std::string &vertGlsl, const std::string &fragGlsl) = 0;
1796 Shader *newShader(const std::string &fragGlsl) { return newShader(std::string(), fragGlsl); }
1797
1808 virtual Shader *newShaderFromWgsl(const std::string &vertWgsl,
1809 const std::string &fragWgsl) = 0;
1810
1822 [[nodiscard]] virtual Result<void> replaceShaderFromSpv(Shader& shader, const std::vector<uint32_t>& vertSpv,
1823 const std::vector<uint32_t> &fragSpv) = 0;
1824
1844 [[nodiscard]] virtual Result<void> replaceMeshShaderResources(Shader &shader, const std::vector<uint32_t> &vertSpv,
1845 const std::vector<uint32_t> &fragSpv,
1847
1858 [[nodiscard]] virtual Result<void> replaceShaderFromWgsl(Shader& shader, const std::string& vertWgsl,
1859 const std::string& fragWgsl) = 0;
1860
1873 Shader &shader, const std::string &vertGlsl, const std::string &fragGlsl) = 0;
1874
1879 virtual Shader *newMeshShaderFromSpv(const std::vector<uint32_t> &vertSpv,
1880 const std::vector<uint32_t> &fragSpv) = 0;
1888 virtual Shader *newMeshShaderFromWgsl(const std::string &vertWgsl,
1889 const std::string &fragWgsl) = 0;
1891 virtual Shader *newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl) = 0;
1898 [[nodiscard]] virtual eve::Result<void> configureMeshShaderSurface(Shader &, BlendMode, bool, bool) {
1901 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "Custom mesh surface state is unavailable"));
1902 }
1920 eve::Diagnostic::error(eve::DiagnosticCode::Unsupported, "Custom mesh raster state is unavailable"));
1921 }
1928 Shader *newMeshShaderVF(const std::string &vertGlsl, const std::string &fragGlsl) {
1930 return newMeshShader(vertGlsl, fragGlsl);
1931 }
1934 Shader *newMeshShader(const std::string &fragGlsl) {
1936 return newMeshShader(std::string(), fragGlsl);
1937 }
1938
1943 virtual Shader *newHairShaderFromSpv(const std::vector<uint32_t> &vertSpv,
1944 const std::vector<uint32_t> &fragSpv) = 0;
1946 virtual Shader* newHairShaderFromWgsl(const std::string& vertWgsl, const std::string& fragWgsl) = 0;
1948 Shader *newHairShader();
1949
1954 Mesh *newHairCardMesh(float width = 0.12f, float height = 0.45f);
1955
1960 Material *newHairCardMaterial(Texture *albedo = nullptr);
1961
1976 virtual bool releaseShader(Shader *shader) {
1977 (void)shader;
1978 return false;
1979 }
1980
1985 Shader *newGrassShader();
1986
1996 Shader* newTreeWindShader();
1997
2002 GrassField *newGrassField();
2003
2012 hair::GroomInstance *newGroomInstance();
2013
2019 Waterfall *newWaterfall();
2020
2025 Water *newWater();
2034 [[nodiscard]] Result<void> configureFoliageWind(Material *material, float directionX, float directionZ,
2035 float strength, float bending, float bendingSpeed, float branch,
2036 float branchSpeed, float flutter, float flutterSpeed,
2037 float fadeDistance, float bendFactor);
2040 ReflectionProbeCapture *newReflectionProbeCapture();
2043 ReflectionProbeRegistry *newReflectionProbeRegistry();
2044
2046 virtual Canvas *newCanvas(int width, int height) = 0;
2047
2055 virtual Canvas *newHDRCanvas(int width, int height) = 0;
2056
2058 virtual void setCanvas(Canvas *canvas) = 0;
2060 void setCanvas() { setCanvas(nullptr); }
2061
2063 virtual bool isCanvasActive() const = 0;
2065 virtual Canvas *getCanvas() const = 0;
2066
2071 Volumetric *newVolumetric();
2073 DepthOfField* newDepthOfField();
2074
2079 AmbientOcclusion *newAmbientOcclusion();
2080
2086 ContactShadow* newContactShadow();
2087
2092 Outline *newOutline();
2094 AlphaMask *newAlphaMask();
2099 MapFog *newMapFog();
2100
2105 GlobalIllumination *newGlobalIllumination();
2106
2111 ScreenSpaceReflection *newScreenSpaceReflection();
2112
2119 AmbientOcclusion *pipelineAmbientOcclusion();
2121 ContactShadow* pipelineContactShadow();
2123 GlobalIllumination *pipelineGlobalIllumination();
2125 ScreenSpaceReflection *pipelineScreenSpaceReflection();
2127 AntiAliasing *pipelineAntiAliasing();
2130 Bloom *pipelineBloom();
2133 DepthOfField *pipelineDepthOfField();
2136 Exposure *pipelineExposure();
2139 DepthPyramid *pipelineDepthPyramid();
2142 Texture *prepareFinalSceneTexture(Texture *scene, Texture *motion = nullptr);
2145 Canvas *pipelineReflectionComposite(int width, int height);
2147 void setFinalSceneTexture(Texture *texture) { finalSceneTexture_ = texture; }
2151 Texture *texture = finalSceneTexture_;
2152 finalSceneTexture_ = nullptr;
2153 return texture;
2154 }
2156 Outline *pipelineOutline();
2157
2162 AntiAliasing *newAntiAliasing();
2163
2165 virtual void draw(Drawable *drawable, const glm::mat4 &m);
2166
2171 virtual void drawOcclusion(Drawable *drawable, const glm::mat4 &m);
2173 virtual void drawOcclusionSolid(float x, float y, float w, float h);
2175 virtual void drawOcclusionTexture(Texture *texture, float x, float y, float w, float h);
2176 // void draw(Texture *texture, Quad *quad, const glm::mat4 &m);
2177 // void drawLayer(Texture *texture, int layer, const glm::mat4 &m);
2178 // void drawLayer(Texture *texture, int layer, Quad *quad, const glm::mat4 &m);
2179 // void drawInstanced(Mesh *mesh, const glm::mat4 &m, int instancecount);
2180
2181
2187 void polyline(const glm::mat4 *vertices, size_t count);
2188
2196 void rectangle(std::string mode, float x, float y, float w, float h);
2197
2209 void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry, int points);
2211 void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry);
2212
2221 void circle(std::string mode, float x, float y, float radius, int points);
2223 void circle(std::string mode, float x, float y, float radius);
2224
2234 void ellipse(std::string mode, float x, float y, float a, float b, int points);
2236 void ellipse(std::string mode, float x, float y, float a, float b);
2237
2249 void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2,
2250 int points);
2252 void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2);
2253
2255 void push(bool all);
2257 void pop();
2258
2260 const glm::mat4 &getTransform() const;
2262 const glm::mat4 &getProjection() const;
2263
2265 void rotate(float r);
2267 void scale(float x, float y = 1.0f);
2269 void translate(float x, float y);
2271 void origin();
2272
2273 // virtual void draw(const DrawCommand &cmd) = 0;
2274 // virtual void draw(const DrawIndexedCommand &cmd) = 0;
2275 // virtual void drawQuads(int start, int count, const vertex::Attributes &attributes, const vertex::BufferBindings
2276 // &buffers, Texture *texture) = 0;
2277
2278protected:
2279 friend class Exposure;
2281 enum class FramePostTarget { SpatialAA, Exposure };
2287 virtual Canvas &prepareFramePostTarget(FramePostTarget target, int width, int height);
2288 Canvas *sharedFramePostTargets_[2]{};
2290 std::unique_ptr<FrameCaptureStore> frameCaptures_;
2293 std::string key;
2294 Texture *texture = nullptr;
2295 };
2296
2298 void requestFileImageDecode(const std::string &key);
2300 bool fileTextureSourceExists(const std::string &filename) const;
2302 void dropDeferredFileTexture(Texture *texture);
2304 virtual bool uploadDeferredFileTexture(Texture *texture, image::ImageData *data);
2311 [[nodiscard]] virtual ResultRef<Texture> requestFileTexture(const std::string &filename) = 0;
2312
2313 std::vector<DeferredFileTexture> deferredFileTextures_;
2314 bool realizingFileTextures_ = false;
2315
2316 int width = 0;
2317 int height = 0;
2318 int pixelWidth = 0;
2319 int pixelHeight = 0;
2320 Color backgroundColor{0.1f, 0.1f, 0.12f, 1.0f};
2321 bool frameHad3D = false;
2323 std::uint64_t mesh3dDrawEpoch_ = 0;
2325 bool recordingEngine3D_ = false;
2326 bool screenReadbackEnabled = false;
2327 bool vsyncEnabled = true;
2328 int presentationVSyncCount_=1;
2329 DisplayOutputMode displayOutputMode_ = DisplayOutputMode::Sdr;
2330 DisplayColorSpace activeDisplayColorSpace_ = DisplayColorSpace::Sdr;
2331 float displayPaperWhiteNits_ = 200.f;
2332 float displayPeakNits_ = 1000.f;
2333 bool graphicsActive = true;
2334 int msaaSamples = 4;
2335 PresentOverlayFn presentOverlayFn_ = nullptr;
2336 void *presentOverlayUser_ = nullptr;
2337 std::vector<std::pair<WindowDestroyedCallback, void *>> windowDestroyedCallbacks_;
2338 Shader *currentShader = nullptr;
2339 Font *currentFont = nullptr;
2340 std::unique_ptr<RenderControl> renderControl_;
2341 std::shared_ptr<PrimitiveScene> primitiveScene_;
2342 std::unique_ptr<AmbientOcclusion> pipelineAO_;
2343 std::unique_ptr<ContactShadow> pipelineContactShadow_;
2344 std::unique_ptr<GlobalIllumination> pipelineGI_;
2345 std::unique_ptr<ScreenSpaceReflection> pipelineSSR_;
2346 std::unique_ptr<AntiAliasing> pipelineAA_;
2347 std::unique_ptr<Bloom> pipelineBloom_;
2348 std::unique_ptr<DepthOfField> pipelineDof_;
2349 std::unique_ptr<Exposure> pipelineExposure_;
2350 bool sceneDepthOfFieldEnabled_ = false;
2351 float sceneDepthOfFieldFocusDistance_ = 10.f;
2352 float sceneDepthOfFieldFocusRange_ = 5.f;
2353 float sceneDepthOfFieldMaximumBlurPixels_ = 8.f;
2354 float sceneDepthOfFieldNearPlane_ = 0.1f;
2355 float sceneDepthOfFieldFarPlane_ = 100.f;
2356 std::unique_ptr<DepthPyramid> pipelineDepthPyramid_;
2357 Canvas *spatialAAResolve_ = nullptr;
2358 int spatialAAResolveWidth_ = 0;
2359 int spatialAAResolveHeight_ = 0;
2360 Canvas *reflectionComposite_ = nullptr;
2361 int reflectionCompositeWidth_ = 0;
2362 int reflectionCompositeHeight_ = 0;
2363 Texture *finalSceneTexture_ = nullptr;
2364 Texture *foliageWindMotionTexture_ = nullptr;
2365 Texture *foliageWindNoiseTexture_ = nullptr;
2366 std::unique_ptr<Outline> pipelineOutline_;
2367
2369 Shader *prepareSceneColorResolveShader(Texture *scene);
2371 void retireResourceLifetime() const;
2372};
2373
2374} // namespace eve::graphics
double y
double m[16]
double x
LogicalId target
bool & active
float w
Definition AnimClip.cpp:738
Vocabulary aliases for nullable and checked borrowed references.
float ao
float normalStrength
float cx
Definition CardTypes.cpp:36
float cy
Definition CardTypes.cpp:37
float degrees
Definition CardTypes.cpp:38
graphics::Texture * albedo
SQObjectPtr key
Definition ECS.cpp:155
#define EVENGINE_API_BACKENDS
Definition Export.h:108
float strength
std::uint32_t vertexCount
std::uint32_t indexCount
tensor::Graph g
Definition GpuGraph.cpp:7
float camera[2]
std::uint32_t instanceCount
POD RGB triple for Graphics tone-map controls without glm headers.
vk::UniqueSampler sampler
vk::UniqueImage image
glm::vec4 tint
glm::mat4 mvp
double r
std::vector< std::uint32_t > indices
float v
std::int32_t c
std::int32_t first
float blend
int h
std::uint32_t height
std::uint32_t width
std::array< float, 3 > scale
ActionGuidePack pack
bool present
std::string coverage
std::vector< RecipeParam > params
bool all
MeleePoint3 b
Definition MeleeHit.cpp:41
double radius
Definition MeleeHit.cpp:42
MeleePoint3 a
Definition MeleeHit.cpp:40
MeshVfxBatchedDraw draw
float roughness
bool doubleSided
Texture * normal
float alphaCutoff
float metallic
OceanMeshSettings mesh
glm::dvec2 center
glm::dvec3 dx
glm::dvec3 displacement
glm::dvec3 dz
OceanSprayView view
std::vector< std::pair< std::uint64_t, OceanBoatReceipt > > sources
std::vector< std::weak_ptr< DeviceBytes > > resources
Definition OnnxGpgpu.cpp:55
std::array< uint32_t, 16 > material
Texture * texture
float f
std::string path
Definition PlayHost.cpp:111
std::shared_ptr< const std::vector< glm::vec2 > > points
std::weak_ptr< PrimitiveScene > scene
int detail
bool lodFadeReverse
glm::vec3 eye
float lodWeight
glm::mat4 viewProj
Shader * shader
bool hair
glm::mat4 model
Move-only, checked operation results for the common layer.
bool repeatV
std::string filter
std::string mipmap
bool repeatU
std::string text
std::string_view source
float dy
Definition Shadow.cpp:151
int count
std::array< double, 2 > vertices[3]
float opacity
float size
Definition TreeMesh.cpp:158
int caps
Definition TreeMesh.cpp:164
V3 dir
Definition TreeMesh.cpp:151
std::uint32_t depth
double weight
double gain
ViewPreparation callback
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Graphics-owned state machine and immutable CPU snapshot authority. @thread Main-thread only; supplied...
Cross-module owner for swapchain presentation cadence.
Render-surface host for the window module (provided by graphics).
EVENGINE_API_FOUNDATION public API.
Definition Module.h:48
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
One-shot borrowed capability pointer for composition roots and hot paths.
Definition Capability.h:107
CPU-side decoded font face (FreeType FT_Face + owned font bytes). Does not upload to GPU — rasterize ...
Definition FontData.h:25
Reusable two-texture alpha mask for immediate 2D composition.
Definition AlphaMask.h:12
Screen-space ambient occlusion.
Classic image-space anti-aliasing.
Linear-HDR bloom pyramid with selectable Karis/tent or Gaussian/scatter reconstruction.
Definition Bloom.h:42
EVENGINE_API_BACKENDS public API.
Canvas public API.
Definition Canvas.h:17
Screen-space contact shadows for the primary directional light.
Separable Gaussian depth-of-field for the final HDR scene.
Cross-backend min/max hardware-depth pyramid packed into one texture atlas.
Drawable base (textures, meshes, canvases).
Definition Drawable.h:18
GPU percentile metering, eye adaptation, and linear HDR pre-exposure.
Definition Exposure.h:14
GPU-side font: wraps a decoded font::FontData and rasterizes a fixed set of codepoints into a single ...
Definition Font.h:35
Screen-space single-bounce GI (SSGI). @lifetime All texture arguments are borrowed for the duration o...
virtual void setFont(Font *font)
Optional shared font used by legacy consumers; nullptr = none set.
Definition Graphics.h:1695
virtual Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces)=0
Create an RGBA8 cubemap from 6 faces packed as +X,-X,+Y,-Y,+Z,-Z (each faceSize×faceSize,...
virtual void beginShadowPass(int cascadeIndex)=0
Depth-only shadow pass for one cascade layer (0..2). Draws are recorded into the next begin3DFrame co...
std::vector< std::pair< WindowDestroyedCallback, void * > > windowDestroyedCallbacks_
Definition Graphics.h:2337
virtual void setMesh3DEnvProbe(const glm::vec3 &center, const glm::vec3 &extent)=0
Box projection bounds for the active environment; zero extent disables it.
virtual void onNativeWindowDestroyed()
Called by the Window module when the native window backing the render surface is destroyed (window cl...
Definition Graphics.h:1641
void(*)(void *userdata) WindowDestroyedCallback
Register a callback invoked when the native window is destroyed. Used by the UI backend to tear down ...
Definition Graphics.h:1659
virtual void setMesh3DReflectionProbes(const ReflectionProbeUpload &upload)=0
Upload the two dominant local reflection probes for subsequent mesh draws.
bool consumeFrameHad3D()
True after begin3DFrame until present completes.
Definition Graphics.h:1547
void drawCanvas(Canvas *canvas, float x, float y, float w, float h)
Draws a Canvas with opaque white tint (script-friendly defaults).
Definition Graphics.h:980
virtual bool updateTexture(Texture *texture, int width, int height, const uint8_t *rgba)=0
Replace an existing texture's pixels in place (pointer stays stable).
virtual bool releaseMesh(Mesh *mesh)
Eagerly releases a mesh created by this Graphics.
Definition Graphics.h:935
void ellipse(std::string mode, float x, float y, float a, float b)
Ellipse.
virtual void setMesh3DSceneColor(Texture *color)=0
Optional completed scene-color snapshot for custom mesh shaders.
virtual bool gpuDrivenSubmitOpaque(const GpuInstance *instances, uint32_t instanceCount)
Upload + record GPU-driven opaque draws (call inside the open 3D frame). The backend sorts instances ...
Definition Graphics.h:352
virtual bool copyHDRCanvasesToCubemap(Canvas *const *sources, int faceCount, Texture *cubemap)
Copy consecutive RGBA16F canvases into cubemap base-level faces.
Definition Graphics.h:577
int getPixelHeight() const
Returns the pixel height.
Definition Graphics.h:495
virtual Texture * getSceneLinearDepthTexture()
Sampleable scene linear depth in [0,1], or nullptr when unavailable.
Definition Graphics.h:1077
virtual void setVSync(bool enabled)
Prefer uncapped present (IMMEDIATE/MAILBOX) when false, vsync (MAILBOX/FIFO) when true....
Definition Graphics.h:1589
virtual image::ImageData * readGBufferToImageData(const std::string &attachment)
Read a G-buffer attachment back to CPU as RGBA8. name is one of "depth" (RGBA8 linear depth),...
Definition Graphics.h:1094
std::unique_ptr< AntiAliasing > pipelineAA_
Definition Graphics.h:2346
virtual IGpuParticles * gpuParticles() noexcept
Borrow the backend particle compute surface when present.
Definition Graphics.h:344
virtual float getSceneAutoExposureMinEV() const =0
Minimum automatic exposure EV.
virtual void drawTexturedRectShader4(Texture *color, Texture *depth, Texture *motion, Texture *extra, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Post draw with four sampled textures at bindings 0, 1, 2 and 3.
virtual Shader * newMeshShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a Mesh3D custom shader (MeshVertex + Frame UBO + albedo). Empty vert → default mesh3d....
virtual bool gpuDrivenCullEnabled() const
True when the stage-2 GPU cull chain will run this frame.
Definition Graphics.h:375
void setBackgroundColor(const Color &c)
Sets the background color.
Definition Graphics.h:1557
virtual void setMesh3DShadows(const ShadowUpload &upload)=0
Upload CSM constants for subsequent default mesh draws (active=false disables).
void ellipse(std::string mode, float x, float y, float a, float b, int points)
Draws an ellipse using the specified arguments.
virtual void endGBufferPass()=0
Ends g buffer pass.
bool isVSync() const
True when v sync.
Definition Graphics.h:1591
virtual void setMesh3DClip(float nearZ, float farZ)=0
Near/far used to pack linear depth into scene color A (SSGI).
virtual void gpuDrivenOpenScenePass()
Open the scene color pass that begin3DFrame deferred (cull path).
Definition Graphics.h:398
void setActive(bool active) override
Pause/resume presenting (mobile background/foreground, desktop minimize/restore).
Definition Graphics.h:1607
void translate(float x, float y)
Translate.
virtual Mesh * newMeshCylinder(int slices=32, int stacks=1, bool caps=true)=0
Procedural Y-up cylinder (radius 1, height 2 centered at origin). slices = longitude divisions; stack...
virtual RgbF getSceneColorFilter() const =0
Current linear RGB multiplier applied during final HDR exposure.
virtual Result< void > replaceShaderFromGlsl(Shader &shader, const std::string &vertGlsl, const std::string &fragGlsl)=0
Compile GLSL and transactionally replace an existing shader.
std::unique_ptr< Outline > pipelineOutline_
Definition Graphics.h:2366
virtual float getSceneAutoExposureMaxEV() const =0
Maximum automatic exposure EV.
virtual void setMesh3DMaterial(float metallic, float roughness)=0
Metallic (0..1) and roughness (0..1) for the next default mesh draw.
virtual bool gpuDrivenVgSetInstance(std::uint32_t vgAssetId, const glm::mat4 &model, std::uint32_t materialId)
Register one instance of a VG asset this frame (model + material). The first instance per asset wins;...
Definition Graphics.h:445
void polyline(const glm::mat4 *vertices, size_t count)
Draws a series of lines connecting the given vertices.
int getWidth() const
Returns the width.
Definition Graphics.h:489
virtual Shader * newHairShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create an alpha-blended hair/card shader from WGSL on WebGPU.
virtual float getSceneTransitionVignetteSmoothness() const =0
Return the final-composite vignette smoothness.
std::unique_ptr< DepthPyramid > pipelineDepthPyramid_
Definition Graphics.h:2356
virtual RgbF getSceneLift() const =0
Current pre-tonemap lift coefficients.
std::unique_ptr< Bloom > pipelineBloom_
Definition Graphics.h:2347
bool isScreenReadbackEnabled() const
True when screen readback enabled.
Definition Graphics.h:1565
virtual float getSceneBloomIntensity() const =0
Current final-scene bloom intensity.
std::vector< DeferredFileTexture > deferredFileTextures_
Definition Graphics.h:2313
virtual std::uint32_t gpuDrivenVgAssetId(Mesh *mesh) const
VG asset id attached to a mesh (kInvalidGpuDrivenSlot when none).
Definition Graphics.h:427
virtual bool releaseTexture(Texture *texture)
Eagerly releases a texture created by this Graphics.
Definition Graphics.h:732
virtual Shader * newShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a 2D custom shader from WGSL source (WebGPU backend). Empty vert → default textured vertex sha...
virtual float getSceneTransitionLensDistortion() const =0
Return the final-composite radial lens-distortion strength.
virtual 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)=0
UV draw with an explicit Shader (nullptr = default textured pipeline).
virtual Shader * newMeshShader(const std::string &vertGlsl, const std::string &fragGlsl)=0
Creates a mesh shader. @ownership Caller deletes unless documented otherwise.
virtual void setMesh3DViewProj(const glm::mat4 &viewProj)=0
Sets the mesh 3 d view proj.
virtual void drawMeshShadow(Mesh *mesh, const glm::mat4 &lightMVP, bool doubleSided=true)=0
Queue an opaque shadow caster.
virtual void drawMesh(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint)=0
Draw one mesh with model matrix. Requires begin3DFrame() (or an open swapchain pass).
virtual void drawMeshShadowAlpha(Mesh *mesh, const glm::mat4 &lightMVP, Texture *albedo=nullptr, bool doubleSided=true, float lodWeight=1.f, bool lodFadeReverse=false, bool lodDither=false)=0
Shadow pass draw with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): tra...
virtual Texture * newTexture(image::ImageData *data)=0
Create texture from ImageData (RGBA8 required for now).
std::shared_ptr< PrimitiveScene > primitiveScene_
Definition Graphics.h:2341
virtual Result< void > setMesh3DPbrSurface(const PbrSurface *surface)
Copy a validated extended surface for subsequent draws; null resets to legacy shading.
Definition Graphics.h:1253
virtual 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)=0
Lit 2D draw rotated degrees clockwise (screen Y-down) around (cx, cy). Fragment tangent frame is rebu...
virtual void setMesh3DCameraPos(const glm::vec3 &eye)=0
Camera eye used by mesh shaders that need view/rim (stored in Mesh3DUBO).
virtual RgbF getSceneGain() const =0
Current pre-tonemap gain coefficients.
virtual void setSceneColorFilter(const RgbF &color)=0
Set a non-negative linear RGB multiplier applied during final HDR exposure.
std::unique_ptr< ScreenSpaceReflection > pipelineSSR_
Definition Graphics.h:2345
FramePostTarget
Internal fully overwritten outputs; temporal histories are excluded.
Definition Graphics.h:2281
virtual uint32_t gpuDrivenMeshRecord(Mesh *mesh)
GPU mesh-table slot for a mesh (kInvalidGpuDrivenSlot when not uploaded).
Definition Graphics.h:296
virtual Mesh * newMeshFromAssimp(const ::aiMesh &mesh, const glm::mat4 &worldTransform)=0
Like newMeshFromAssimp, but bakes a column-major world transform into positions and transforms normal...
Color getBackgroundColor() const
Returns the background color.
Definition Graphics.h:1555
void addWindowDestroyedCallback(WindowDestroyedCallback cb, void *userdata)
Adds window destroyed callback.
Definition Graphics.h:1661
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:1602
virtual bool getSceneAutoExposure() const =0
Whether automatic exposure is active.
virtual void endShadowPass()=0
Ends shadow pass.
virtual void setLighting2D(const Lighting2DUBO &ubo)=0
Upload per-frame / per-canvas 2D lighting constants for subsequent lit draws.
void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2, int points)
Draws an arc using the specified arguments.
virtual void setMesh3DPackedNormalMask(bool enabled)=0
Interpret normal texture RG as tangent XY, B as AO and A as smoothness for terrain surfaces.
void push(bool all)
Pushes .
virtual image::ImageData * readDecalLayerToImageData(const std::string &attachment)
Read back a DecalLayer attachment ("albedo" | "normal" | "params") to CPU. Renders the pending G-buff...
Definition Graphics.h:1104
virtual float getSceneTransitionVignette() const =0
Return the final-composite vignette strength.
virtual void setMesh3DSSAO(float intensity)=0
Sets the screen-space ambient-occlusion strength applied in the forward mesh pass....
std::unique_ptr< DepthOfField > pipelineDof_
Definition Graphics.h:2348
virtual Mesh * newMeshFromAssimp(const ::aiMesh &mesh)=0
Creates a mesh from assimp. @ownership Caller deletes unless documented otherwise.
virtual void setMesh3DClusteredActive(bool active)=0
Cheap per-draw toggle for the already-uploaded clustered light table. Unlike setMesh3DClusteredLighti...
virtual RgbF getSceneInverseGamma() const =0
Current pre-tonemap inverse-gamma coefficients.
virtual void setSceneLiftGammaGain(const RgbF &lift, const RgbF &inverseGamma, const RgbF &gain)=0
Set pre-tonemap HDR lift, inverse-gamma and gain coefficients.
double getScreenDPIScale() const
Returns the screen dpi scale.
Definition Graphics.h:500
virtual bool copyHDRCanvasToCubemapFace(Canvas *source, Texture *cubemap, int face)
Copy one RGBA16F Canvas into a staging cubemap base-level face.
Definition Graphics.h:559
virtual void begin3DFrameToCanvas(Canvas *canvas)=0
Open a 3D render pass targeting an offscreen Canvas (color + depth) at the canvas size....
virtual eve::Result< void > updateTextureFromResidentRgba8(Texture *texture, const GpuResidentBufferView &source, int width, int height)
Copy a same-device resident RGBA8 buffer into an existing texture.
Definition Graphics.h:630
virtual SceneColorDistortionStatus drawSceneColorDistortionUVRotated(Texture *displacement, float cx, float cy, float w, float h, float degrees, float u0, float v0, float u1, float v1, float strengthPixels, float opacity, bool rotatedUV=false)
Draws scene color distortion uv rotated.
Definition Graphics.h:795
virtual void setMesh3DEnv(Texture *cube, float intensity)=0
Specular IBL environment for subsequent default mesh draws. cube must be from newCubemap (or nullptr ...
std::unique_ptr< FrameCaptureStore > frameCaptures_
Definition Graphics.h:2290
virtual bool gpuDrivenMaterialUsable(Material *material)
Whether a material can be shaded by the GPU-driven opaque path. Backends/drivers with descriptor-inde...
Definition Graphics.h:326
virtual void setMesh3DLodDither(float weight, bool reverse, bool enabled)=0
Set opaque LOD dither coverage for the next default mesh draw. Render-thread only.
SceneColorDistortionStatus
Refract the resolved 3D scene color through a displacement texture.
Definition Graphics.h:792
virtual void setMesh3DTexCellBomb(float cellScale, float strength, float rotAmount=1.f)=0
Texture cell bombing for the next default mesh draw (breaks tiling). cellScale: cells per UV unit (ty...
virtual void beginDecalPass(int width, int height)=0
Open the decal pass (reads G-buffer hwDepth + normal, writes the screen-space DecalLayer targets)....
virtual Canvas * getCanvas() const =0
Returns the canvas.
virtual void initWithWindow(void *nativeWindow)=0
Bind to an existing native window (SDL_Window*) and create Vulkan device/swapchain....
virtual float getScenePhotographicVignette() const
Return photographic vignette intensity; render thread only.
Definition Graphics.h:1448
virtual float getSceneBloomThreshold() const =0
Current linear HDR bloom threshold.
virtual void setSceneExposure(float exposure)=0
Set linear exposure multiplier used by the final scene tone-map resolve.
virtual GpuResidentSubmitStatus gpuDrivenSubmitResident(const GpuResidentInstanceBatch &batch)
Submit a GPU-authored, bucket-sorted GpuInstance buffer without CPU readback.
Definition Graphics.h:365
void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry, int points)
Variant of rectangle that draws a rounded rectangle.
DisplayOutputMode
Requested swapchain present preference.
Definition Graphics.h:1388
virtual void popValidationScope()=0
Pops validation scope.
void arc(std::string mode, std::string arcmode, float x, float y, float radius, float angle1, float angle2)
Arc.
void rectangle(std::string mode, float x, float y, float w, float h, float rx, float ry)
Rectangle.
virtual void pushValidationScope()=0
Backend hooks so the platform-independent render3D() can wrap its work in a GPU validation error scop...
virtual void beginGBufferPass(int width, int height)=0
Depth/normal(/albedo) fill pass for mid/post effects. One-shot submit (like shadow); call before begi...
virtual void setMesh3DClusteredLighting(const ClusteredLightingUpload &upload)=0
Enable clustered forward path for subsequent default mesh draws (SSBO light lists)....
virtual void setMesh3DParallax(float scale, float minLayers=8.f, float maxLayers=32.f)=0
Parallax occlusion mapping for the next default mesh draw. scale: UV displacement strength (0=off)....
void rectangle(std::string mode, float x, float y, float w, float h)
Draws a rectangle.
void circle(std::string mode, float x, float y, float radius)
Circle.
virtual void setSceneBloom(float intensity, float threshold)=0
Configure final HDR bloom intensity and linear threshold.
void clearPresentOverlay()
Drop the present overlay callback (window gone; re-register on UI init).
Definition Graphics.h:1649
virtual Shader * newShader(const std::string &vertGlsl, const std::string &fragGlsl)=0
Compile GLSL source with the engine's build-time GLSL compiler. Empty vertGlsl → default textured ver...
virtual bool filterHDRReflectionCubemap(Texture *cubemap, int sampleCount=64)
Generate GGX specular mips and final diffuse irradiance for an HDR cubemap. @compatibility Preserves ...
Definition Graphics.h:588
virtual 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)=0
UV draw rotated degrees clockwise (screen Y-down) around the rect center. texture may be null → solid...
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, bool repeatU=false, bool repeatV=false)=0
Creates a texture. @ownership Caller deletes unless documented otherwise.
virtual 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)=0
Queue one box-projected decal draw. model maps the unit decal box ([-0.5, 0.5]^3, +Z = decal forward)...
void setCanvas()
Sets the canvas.
Definition Graphics.h:2060
virtual bool reloadTextureFromFile(const std::string &filename)=0
Reload a path-cached texture from disk in place (pointer stable). False if unbound.
virtual void setMesh3DVirtualTexture(bool enabled, int pageCountX, int pageCountY, int atlasSlotsX, int atlasSlotsY, float borderFraction)=0
Configure page-table sampling for the next mesh draw.
std::shared_ptr< PrimitiveScene > getPrimitiveScene() const noexcept
Returns the authoritative persistent spatial-primitive scene.
Definition Graphics.h:508
Shader * newMeshShaderVF(const std::string &vertGlsl, const std::string &fragGlsl)
Creates a Mesh3D shader from separate vertex and fragment GLSL sources.
Definition Graphics.h:1928
virtual bool updateMeshVertices(Mesh *mesh, const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
In-place update of a mesh's vertex/index data (CPU -> host-visible VBO). Only call when content chang...
virtual void setMesh3DView(const glm::mat4 &view)=0
Camera view matrix for subsequent drawMesh (view-space depth / CSM select).
virtual ResultRef< Texture > requestFileTexture(const std::string &filename)=0
Canonical checked cache request; pixel realization is performed by loadTexture or legacy consumers....
virtual Result< void > drawMeshInstances(Mesh &mesh, std::span< const glm::mat4 > models, OptionalRef< Texture > texture, const Color &tint)
Draw a batch of static meshes using the current ordinary material and lighting bindings.
Definition Graphics.h:1151
virtual float getLastOffscreen3DGpuDurationMs() const
Return the GPU timestamp duration of the most recently completed offscreen 3D pass,...
Definition Graphics.h:1058
virtual IVisibilityCapture * visibilityCapture() noexcept
Borrow the entity-ID / isolated visibility capture surface when present.
Definition Graphics.h:1085
virtual void setCloudShadows(float strength, float worldCell, float time, float windSpeed, float windAngle, float coverage, float detail)=0
Dynamic cloud shadows cast on the ground by the default PBR mesh path. strength 0 disables (no change...
virtual bool gpuDrivenScenePassPending() const
Scene pass opening deferred until after the compute cull section.
Definition Graphics.h:378
virtual void gpuDrivenResolve()
Record the fullscreen vis resolve inside the open scene color pass.
Definition Graphics.h:414
virtual eve::Result< void > configureMeshShaderRaster(Shader &shader, const MeshShaderRasterState &state)
Transactionally configure an owned ordinary mesh shader's raster state.
Definition Graphics.h:1915
SceneToneMapping
Final display mapping; None preserves linear color, Aces uses the fitted curve, and Filmic uses Rec....
Definition Graphics.h:1386
const glm::mat4 & getProjection() const
Returns the projection.
Shader * newShader(const std::string &fragGlsl)
Creates a shader. @ownership Caller deletes unless documented otherwise.
Definition Graphics.h:1796
virtual Shader * newHairShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Hair/fur card shader (alpha blend + Kajiya-Kay). Empty vert → mesh3d_hair.vert. Owned by Graphics.
std::unique_ptr< ContactShadow > pipelineContactShadow_
Definition Graphics.h:2343
virtual void drawSolidRectRotated(float cx, float cy, float w, float h, float degrees, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Rotated solid quad degrees clockwise (screen Y-down) around (cx, cy).
std::unique_ptr< Exposure > pipelineExposure_
Definition Graphics.h:2349
virtual void setMesh3DLight(const glm::vec3 &dir, const glm::vec3 &color)=0
Directional light for subsequent drawMesh calls (world-space direction toward surface).
virtual bool beginFrameReadback(const std::string &path)
Queue an asynchronous readback of the current frame to a PNG file.
Definition Graphics.h:1578
virtual bool releaseShader(Shader *shader)
Eagerly releases a shader created by this Graphics.
Definition Graphics.h:1976
virtual 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)=0
Instanced voxel face rectangles (32-bit packed instances). ao: optional per-instance ambient-occlusio...
virtual void setCanvas(Canvas *canvas)=0
nullptr or this → screen. Switching flushes pending draws to the previous target.
bool had3DThisFrame() const
Had 3 d this frame.
Definition Graphics.h:1552
virtual bool isCanvasActive() const =0
True when canvas active.
virtual float getSceneExposure() const =0
Current linear manual exposure multiplier.
virtual void drawTexturedRectShaderDepthMotion(Texture *color, Texture *depth, Texture *motion, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Post draw with color, depth/history and motion/reactive textures.
virtual float getMaxAnisotropy() const =0
Device max supported anisotropy (1 if unsupported). Valid after initWithWindow.
virtual void setSceneTransitionFx(float vignette, float vignetteSmoothness, float lensDistortion, float lensScale)=0
Set final-composite vignette and radial lens distortion strengths in [0,1].
virtual Result< void > drawMeshShaderInstances(Mesh &mesh, Shader &shader, const glm::mat4 &model, const Color &tint, std::uint32_t first, std::uint32_t count)
Draw a checked range from a resource shader's immutable instance matrix buffer. @ownership Mesh and S...
Definition Graphics.h:1175
std::unique_ptr< RenderControl > renderControl_
Definition Graphics.h:2340
virtual void setDecalCamera(const glm::mat4 &viewProj, float nearZ, float farZ)=0
Per-frame camera constants for the decal pass (world-space reconstruction from the G-buffer depth)....
virtual void markSwapchainDirty()
Request swapchain recreation on next present/begin3DFrame.
Definition Graphics.h:1619
bool isActive() const
True when active.
Definition Graphics.h:1616
const glm::mat4 & getTransform() const
Returns the transform.
virtual void setMesh3DSurface(SurfaceMode mode, BlendMode blend, bool depthWrite, bool doubleSided, float alphaCutoff, const std::string &alphaTechnique="cutoff")=0
Select pipeline state for subsequent mesh draws.
void drawTextRGBA(Font *font, const std::string &text, float x, float y, float r, float g, float b, float a, float scale=1.f)
Script-friendly UTF-8 text drawing overload using RGBA components.
Definition Graphics.h:1742
int getVSyncCount() const noexcept override
Returns the v sync count.
Definition Graphics.h:1595
virtual void drawTexturedRectUV(Texture *texture, float x, float y, float w, float h, float u0, float v0, float u1, float v1, const Color &color)=0
Draw a textured sub-rect (atlas / tile UVs). texture may be null → solid.
void scale(float x, float y=1.0f)
Scale.
virtual bool isHeadless() const
True when the renderer was initialized via initHeadless().
Definition Graphics.h:481
virtual Texture * newTexture(int width, int height, const uint8_t *rgba, const TextureCreateInfo &info)=0
Creates a texture. @ownership Caller deletes unless documented otherwise.
virtual void setSceneAutoExposure(bool enabled, float minEV, float maxEV)=0
Configure log-average scene auto exposure and its EV clamp range.
virtual int getMsaaSamples() const
Returns the msaa samples.
Definition Graphics.h:1604
virtual float getSceneDofFarZ() const =0
Returns the scene dof far z.
virtual bool setMeshSkinningData(Mesh *mesh, const uint16_t *joints4, const float *weights4, int vertexCount)
Upload four joint indices and weights per vertex for built-in GPU skinning.
Definition Graphics.h:890
void rotate(float r)
Rotate.
virtual void setMesh3DSceneDepth(Texture *depth)=0
Optional scene hardware depth (G-buffer hwDepth, Vulkan NDC z) bound to mesh3d shader binding 7....
virtual void gpuDrivenSetEnabled(bool enabled)
Enable/disable the GPU-driven opaque path (no-op when unsupported).
Definition Graphics.h:293
virtual 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)=0
GBuffer fill with alpha-cutout discard (card/billboard geometry such as sprite-stack slices): same ou...
void setVSyncCount(int count) override
Sets the v sync count.
Definition Graphics.h:1593
virtual int frameReadbackStatus() const
Async readback state: 0=idle, 1=pending, 2=done, 3=failed.
Definition Graphics.h:1583
virtual uint32_t gpuDrivenMaterialRecord(Material *material)
GPU material-table slot for a material (lazily created).
Definition Graphics.h:302
virtual bool bakeMeshMorph(Mesh *mesh)=0
If mesh morph weights are dirty, bake blended positions and upload to the GPU VBO....
virtual void setMesh3DSkinInfluenceLimit(SkinInfluenceLimit count)=0
Limit GPU skinning to the strongest one, two or four vertex influences.
virtual bool gpuDrivenResolveWanted() const
True when the stage-3 vis+resolve path should run this frame.
Definition Graphics.h:408
virtual void gpuDrivenRecordVisPass()
Record the GBuffer vis pass (opaque indirect draws write visID/visBary).
Definition Graphics.h:411
Shader * getShader() const
Returns the shader.
Definition Graphics.h:1772
virtual Shader * newShaderFromSpv(const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Create a custom 2D shader from SPIR-V words (vert + frag). Owned by Graphics. Vertex stage may be emp...
virtual void setMesh3DShadowReceive(bool receive)=0
Per-draw: when false, shadow sampling is forced off for the next mesh draw.
virtual bool supportsGBufferPost() const
Whether gbuffer-based post-process shaders (AO, GI) can be created on this backend....
Definition Graphics.h:260
virtual Mesh3DSceneColorCaptureStatus captureMesh3DSceneColor()
Make opaque scene color available to subsequent refractive mesh draws.
Definition Graphics.h:1242
virtual void begin3DFrame()=0
Begin a 3D frame: shadow/gbuffer (if pending) then a sampleable scene color pass (color+depth)....
void setFinalSceneTexture(Texture *texture)
Override the HDR source consumed by the next backend scene resolve.
Definition Graphics.h:2147
virtual eve::Result< void > updateTextureRegions(Texture *texture, std::span< const TextureRegionUpload > regions)=0
Validate then upload multiple independent mip-zero RGBA8 regions as one batch.
virtual eve::Result< void > configureMeshShaderSurface(Shader &, BlendMode, bool, bool)
Prepare a custom mesh shader's blend, depth and culling state.
Definition Graphics.h:1898
std::unique_ptr< GlobalIllumination > pipelineGI_
Definition Graphics.h:2344
eve::cap::ProviderRef< IRayTracing > rayTracing_
Definition Graphics.h:2289
virtual bool supportsGpuDriven3D() const
True when the backend can run GPU-driven opaque draws.
Definition Graphics.h:277
virtual uint32_t gpuDrivenReflectionProbeSlot(Texture *cubemap)
Return/register a bindless cubemap slot for a GPU-driven local probe.
Definition Graphics.h:332
Mesh3DSceneColorCaptureStatus
Observable result of requesting a same-frame mesh SceneColor snapshot.
Definition Graphics.h:1227
void requestSurfaceRecreate() override
Request recreation of the platform render surface on the next frame (Android background/foreground de...
Definition Graphics.h:1626
std::unique_ptr< AmbientOcclusion > pipelineAO_
Definition Graphics.h:2342
virtual void setTextureSampler(Texture *texture, const TextureSampler &sampler)=0
Set desired sampler state; equal state is a no-op and repeated edits coalesce. @thread Graphics threa...
virtual float getSceneDofNearZ() const =0
Returns the scene dof near z.
virtual 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)=0
Queue a GBuffer surface using the currently bound PBR material when present.
virtual void drawTexturedRect(Texture *texture, float x, float y, float w, float h, const Color &color)=0
Draws textured rect.
virtual Canvas * newHDRCanvas(int width, int height)=0
Create an engine-internal linear RGBA16F post-process target.
virtual Result< void > drawMeshResidentVertices(Mesh &mesh, const GpuResidentBufferView &source)
Draw a mesh using a producer-owned packed resident vertex stream. Stream ABI: 22 float words per vert...
Definition Graphics.h:1119
virtual void gpuDrivenCullEmit(const glm::mat4 &viewProj, const glm::vec3 &eye, float fovYDeg, float nearZ, float farZ)
Record the cull + emit compute dispatches for the current frame.
Definition Graphics.h:388
virtual float getSceneDofFocusDistance() const =0
Returns the scene dof focus distance.
void drawScene3D(float x, float y, float w, float h)
Script-friendly 4-arg form (simplesquirrel does not apply C++ defaults).
Definition Graphics.h:974
bool(*)(void *userdata, void *commandBuffer) PresentOverlayFn
Optional overlay drawn inside the swapchain render pass (before end). Used by declarative UI (ImGui)....
Definition Graphics.h:1671
Shader * newShaderFromSpvFile(const std::string &fragPath)
Creates a shader from spv file. @ownership Caller deletes unless documented otherwise.
Definition Graphics.h:1784
virtual void gpuDrivenDrawOpaque()
Draw the opaque geometry with GPU-written indirect commands.
Definition Graphics.h:401
virtual bool gpuDrivenEnabled() const
Whether the GPU-driven opaque path is currently enabled.
Definition Graphics.h:290
virtual Texture * getSceneColorTexture()
Sampleable 3D color target for the current frame (RGB = lit, A = linear depth). Valid after begin3DFr...
Definition Graphics.h:1075
virtual void drawMeshShader(Mesh *mesh, const glm::mat4 &model, Texture *texture, const Color &tint, Shader *shader)=0
Draw mesh with an explicit Mesh3D Shader (nullptr = default PBR pipeline).
virtual bool supportsDeferredLighting() const
True when the backend can run Hybrid clustered deferred lighting.
Definition Graphics.h:267
void printRGBA(const std::string &text, float x, float y, float r, float g, float b, float a, float scale=1.f)
Script-friendly stateful print overload using RGBA components.
Definition Graphics.h:1761
virtual float getSceneTransitionLensScale() const =0
Return the final-composite lens scaling factor.
virtual bool supportsRayTracing() const
True when the Vulkan device enabled the KHR ray-tracing path. WebGPU and software devices return fals...
Definition Graphics.h:284
virtual void gpuDrivenVgComputeSection(const glm::mat4 &viewProj, const glm::vec3 &eye, float fovYDeg, float nearZ, float farZ)
Record the HZB build + cull-params section (VG-only frames).
Definition Graphics.h:454
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
Font * getFont() const
Returns the font.
Definition Graphics.h:1697
virtual eve::Result< MeshBackendDescriptor > describeMesh(Mesh *mesh) const
Describe a live mesh created by this Graphics backend.
Definition Graphics.h:863
virtual SceneToneMapping getSceneToneMapping() const
Return the current final display mapping; graphics/render thread only.
Definition Graphics.h:1408
virtual void endDecalPass()=0
Ends decal pass.
virtual Result< void > replaceShaderFromSpv(Shader &shader, const std::vector< uint32_t > &vertSpv, const std::vector< uint32_t > &fragSpv)=0
Transactionally replace an existing shader with SPIR-V stages.
virtual void drawSolidRect(float x, float y, float w, float h, const Color &color, BlendMode blend=BlendMode::Alpha)=0
Internal immediate-mode helper used by RenderSystem / Batcher.
virtual 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)=0
Post draw with five sampled textures at bindings 0 through 4.
Shader * newMeshShader(const std::string &fragGlsl)
Creates a mesh shader. @ownership Caller deletes unless documented otherwise.
Definition Graphics.h:1934
virtual void end3DFrameToCanvas()=0
Ends 3 d frame to canvas.
std::uint64_t mesh3dDrawEpoch() const noexcept
Monotonic epoch advanced at the start of each render3D() submission. Materials use this to run virtua...
Definition Graphics.h:947
virtual float getSceneDofMaxBlur() const =0
Returns the scene dof max blur.
PresentOverlayFn getPresentOverlay() const
Returns the present overlay.
Definition Graphics.h:1678
virtual Canvas * newCanvas(int width, int height)=0
Create an offscreen render target (sampleable). Owned by Graphics.
virtual Result< void > replaceShaderFromWgsl(Shader &shader, const std::string &vertWgsl, const std::string &fragWgsl)=0
Transactionally replace an existing shader with WGSL stages.
DisplayColorSpace
Color space actually selected for the live swapchain.
Definition Graphics.h:1390
virtual bool gpuDrivenVgAttachToMesh(Mesh *mesh, std::uint32_t vgAssetId)
Attach an uploaded VG asset to a mesh (routes it to the VG path).
Definition Graphics.h:433
virtual void drawDeferredLighting()
Fullscreen deferred lighting into the open scene-color pass. Samples GBuffer + clustered lights + CSM...
Definition Graphics.h:274
virtual bool supportsMeshInstancing() const
Whether the initialized backend can instance ordinary opaque meshes without bindless textures....
Definition Graphics.h:1136
virtual Shader * newMeshShaderFromWgsl(const std::string &vertWgsl, const std::string &fragWgsl)=0
Create a Mesh3D custom shader from WGSL source (WebGPU backend). The WGSL must declare the engine's F...
virtual eve::Result< void > updateTextureRegion(Texture *texture, int x, int y, int width, int height, std::span< const std::uint8_t > rgba, std::size_t bytesPerRow=0)=0
Upload one tightly packed or row-strided RGBA8 rectangle into mip level zero.
virtual void setScreenReadbackEnabled(bool enabled)
When true, each present copies the swapchain to a CPU buffer for getPixel/newImageData....
Definition Graphics.h:1563
int getPixelWidth() const
Returns the pixel width.
Definition Graphics.h:493
virtual Mesh * newMeshFromArraysColored(const float *posXYZ, const float *nrmXYZ, const float *uvST, const float *colorRGBA, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh with an optional packed RGBA color per vertex.
virtual bool supportsDecal() const
True when the backend can render the screen-space decal layer (box-projected decals writing albedo/no...
Definition Graphics.h:1335
virtual Mesh * newMeshSphere(int slices=32, int stacks=16)=0
Procedural UV sphere (radius 1, Y-up). Owned by Graphics. slices = longitude divisions,...
virtual Texture * newTexture(image::ImageData *data, const TextureCreateInfo &info)=0
Create texture from ImageData with sampler / mipmap options.
virtual void setViewportSize(int width, int height, int pixelwidth, int pixelheight)=0
Sets the current graphics display viewport dimensions.
virtual 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)=0
Lit 2D draw (albedo + normal map). Uses Lighting2DUBO from setLighting2D. normal may be null → treate...
int getHeight() const
Returns the height.
Definition Graphics.h:491
Texture * takeFinalSceneTexture()
Consume and clear the per-frame HDR scene resolve override. @lifetime Returned texture is borrowed an...
Definition Graphics.h:2150
void * getPresentOverlayUser() const
Returns the present overlay user.
Definition Graphics.h:1680
void setPresentOverlay(PresentOverlayFn fn, void *userdata)
Sets the present overlay.
Definition Graphics.h:1673
void circle(std::string mode, float x, float y, float radius, int points)
Draws a circle using the specified arguments.
virtual RayTracingCaps rayTracingCaps() const
Probed ray-tracing capabilities (empty when unsupported).
Definition Graphics.h:287
virtual Shader * newShaderFromSpvFile(const std::string &vertPath, const std::string &fragPath)=0
Load SPIR-V from files via Filesystem (empty vertPath → default textured vert).
virtual Result< void > gpuDrivenReleaseMaterialRecord(Material *material)
Release a lazily-created GPU material-table record.
Definition Graphics.h:314
virtual void drawTexturedRectShader(Texture *texture, Shader *shader, float x, float y, float w, float h, const Color &color)=0
Draw with an explicit Shader (nullptr = default textured pipeline).
double getCurrentDPIScale() const
Returns the current dpi scale.
Definition Graphics.h:498
virtual void applyPendingResourceChanges()
Publish queued resource state before its next consuming draw. @thread Graphics thread; no callbacks....
Definition Graphics.h:2308
virtual void setMesh3DNormalTexture(Texture *normal)=0
Optional normal map for the next drawMesh / drawMeshShader (nullptr = flat).
virtual bool gpuDrivenCullBegin(const GpuInstance *instances, uint32_t instanceCount)
Upload sorted instances + bucket metadata for the cull chain.
Definition Graphics.h:381
virtual void setMesh3DHeightTexture(Texture *height)=0
Optional height map for parallax (R channel; nullptr = flat / off).
virtual Texture * newCubemap(int faceSize, const uint8_t *rgbaFaces, const TextureCreateInfo &info)=0
Cubemap with GGX specular mips and final diffuse-irradiance mip.
virtual void setMesh3DLighting(const Lighting3DPack &pack)=0
Per-frame ambient + up to 8 lights packed into Mesh3DUBO.
virtual std::uint32_t gpuDrivenVgUpload(const GpuVgAssetUpload &asset)
Upload a virtual-geometry asset into the shared cluster pool.
Definition Graphics.h:421
virtual void drawTexturedRectShaderDepth(Texture *color, Texture *depth, Shader *shader, float x, float y, float w, float h, const Color &tint)=0
Fullscreen/post draw sampling color at binding 0 and depth at binding 1 (hardware D32,...
virtual float getSceneDofFocusRange() const =0
Returns the scene dof focus range.
virtual Texture * newHDRCubemap(int faceSize)
Allocate a linear RGBA16F six-layer staging cubemap for runtime capture.
Definition Graphics.h:549
Dense grass + sparse dark tufts on a mesh. Caller owns GrassField*; GPU Mesh / Shader / Texture are o...
Definition Grass.h:193
Narrow offscreen-Canvas allocation boundary for tools and optional modules.
Narrow render-target binding boundary for optional tooling modules.
Resident GPU particle surface kept off the high-fanout Graphics facade.
2D immediate-mode drawing surface (screen or offscreen Canvas).
Definition IGraphics2D.h:33
3D frame / mesh / light / shadow rendering surface.
Definition IGraphics3D.h:36
Post-process / special-effect object factory.
Definition IPostFX.h:22
Texture / mesh / shader / canvas creation and release.
Narrow solid-rectangle draw boundary for UI/debug tooling.
Offscreen entity-ID and isolated visibility capture surface.
SLG / large-map war-fog overlay driven by a dual-scrolling cloud texture and an RGBA mask bridge (R u...
Definition MapFog.h:18
Packages shading method + surface parameters into one attachable asset.
Definition Material.h:38
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:26
Screen-space model outline (t3ssel8r-style), computed from the GBuffer hardware depth + world-normal ...
Definition Outline.h:33
Authoritative owner for primitives that persist across frames.
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:11
Incremental six-face HDR scene capture for a runtime reflection probe.
Scene-level stable selection of published reflection probes for a camera.
Declarative, compilable 3D render control.
Default renderable entity for declarative 2D sprites / solid quads.
Screen-space reflections (SSR) as a fullscreen post pass. @lifetime All Graphics and texture argument...
Custom GPU program.
Definition Shader.h:41
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
Volumetric light + fog.
Definition Volumetric.h:38
Dynamic water surface with sky reflection and animated ripples.
Definition Water.h:68
Flowing waterfall (falling water sheet) rendered on a vertical plane.
Definition Waterfall.h:33
Runtime groom drawable (UE UGroomComponent analogue).
Represents raw pixel data.
Definition ImageData.h:38
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
SurfaceMode
How a 3D surface contributes to depth and color passes.
Definition SurfaceMode.h:6
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
constexpr uint32_t kInvalidGpuDrivenSlot
GPU-driven API surface without GLM layout records.
SkinInfluenceLimit
Number of strongest vertex influences retained by GPU skinning.
Definition IGraphics3D.h:20
GpuResidentSubmitStatus
Structured result for direct resident-instance submission.
eve::Subscription Subscription
Compatibility alias for the common observer lifetime token.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
std::optional< std::reference_wrapper< T > > OptionalRef
Optional borrowed reference; it does not extend T's lifetime.
Definition BorrowedRef.h:24
BlendMode
Render-neutral 2D blend mode shared by graphics-facing modules.
Definition RenderTypes.h:11
SettlementPipeline::Stage fn
bool enabled
Transient backend buffer slice shared between sibling GPU modules. @ownership Non-owning; nativeHandl...
CPU-built clustered lighting upload for one frame/camera. Point lights are clustered; directional lig...
Per-instance GPU record (std430). Mirrors GLSL GpuInstance.
Direct-render description for a GPU-authored array of GpuInstance records. @ownership buckets and buf...
Neutral GPU upload for one virtual-geometry asset. Raw arrays so the graphics module does not depend ...
DeferredFileTexture public API.
Definition Graphics.h:2292
Surface present formats the current device/window can offer.
Definition Graphics.h:1392
Lighting2DUBO public API.
Definition Light.h:52
Lighting3DPack public API.
Definition Light.h:171
Backend-owned layout facts for a mesh uploaded through Graphics.
Definition Graphics.h:92
Value snapshot of custom mesh rasterization state, independent of blending/culling.
Owning material parameter snapshot; texture pointers remain borrowed. Base color/metallic/roughness c...
Definition PbrSurface.h:240
Hardware ray-tracing capabilities probed once at Vulkan device creation.
ReflectionProbeUpload public API.
Linear RGB triple used by scene color-grade getters/setters.
Definition GraphicsRgb.h:11
Inputs for descriptor set 1 of a resource mesh program.
ShadowUpload public API.
Definition Shadow.h:62
Options for Graphics::newTexture / newCubemap. When generateMipmaps is true and sampler....
One borrowed RGBA8 source rectangle for a batched texture update. @ownership rgba remains owned by th...
Definition Graphics.h:76
std::span< const std::uint8_t > rgba
Definition Graphics.h:81
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...
glm::uvec4 info
glm::vec4 color