载入中...
搜索中...
未找到
OceanGpuSpectrum.cpp
浏览该文件的文档.
70OceanGpuSpectrumBuilder::OceanGpuSpectrumBuilder(const OceanSeaTransition& transition, graphics::Graphics& graphics,
85 diagnostic(DiagnosticCode::Unsupported, "Ocean FFT requires an available Vulkan compute provider"));
102 gpgpu::createComputeShader(std::vector<uint32_t>(ocean_fft_spv, ocean_fft_spv + ocean_fft_spv_count));
106 gpgpu::createComputeShader(std::vector<uint32_t>(ocean_pack_spv, ocean_pack_spv + ocean_pack_spv_count));
111 return Output::failure(diagnostic(DiagnosticCode::Unsupported, "Ocean GPU command sequence unavailable"));
121 return Output::failure(diagnostic(DiagnosticCode::Unsupported, "Ocean GPU allocation unavailable"));
125 layout.bands[layout.bandCount++] = {source.settings.resolution, layout.height, source.settings.length};
150 diagnostic(DiagnosticCode::Failed, "Rebuild the ocean GPU projection after a backend failure"));
159 const double u = state.target ? std::clamp((time_ - state.start) / state.duration, 0.0, 1.0) : 0.0;
162 const double levelDelta = state.target ? state.target->settings.seaLevel - state.data->settings.seaLevel : 0.0;
211 state.evolve->setFloat(6, state.target ? static_cast<float>(state.target->settings.choppiness) : 0.0F);
237 return Output::failure(diagnostic(DiagnosticCode::Failed, "Ocean GPU submission did not complete"));
251Result<OceanGpuBandView> OceanGpuSpectrum::band(const OceanGpuFrameToken& token, unsigned index) const {
253 if (state.lifetime.expired() || state.status != Impl::State::Ready || token.owner_ != state.owner ||
255 return Result<OceanGpuBandView>::failure(diagnostic(DiagnosticCode::StaleHandle, "Ocean GPU frame is stale"));
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Move-only RAII token that owns one observer registration.
Definition Subscription.h:27
void dispose() noexcept
Cancels this registration; safe to call repeatedly.
Definition Subscription.cpp:25
Synchronous borrowed submission builder; do not retain across owner destruction.
Definition OceanGpuSpectrum.h:112
EVENGINE_API_DOMAINS Result< OceanGpuFrameToken > submit() const
Evolve all six spectral fields and inverse FFT in one command sequence; no CPU readback....
Definition OceanGpuSpectrum.cpp:143
Opaque revision of a completed GPU ocean; copying does not extend resource lifetime.
Definition OceanGpuSpectrum.h:22
Borrowed diagnostic readback builder; revision checked again at build, never silently reads a newer f...
Definition OceanGpuSpectrum.h:129
EVENGINE_API_DOMAINS Result< OceanSpectrumFrame > build() const
Download a completed projection into an owning CPU frame for parity tests and diagnostics....
Definition OceanGpuSpectrum.cpp:270
EVENGINE_API_DOMAINS Result< std::unique_ptr< OceanGpuSpectrum > > build() const
Allocate compiled pipelines and band buffers; Unsupported explicitly selects a caller-chosen CPU path...
Definition OceanGpuSpectrum.cpp:79
EVENGINE_API_DOMAINS OceanGpuSpectrumBuilder(const OceanSpectrum &spectrum, graphics::Graphics &graphics, gpgpu::Gpgpu &compute)
Graphics must be the active same-device provider used by the injected Gpgpu service.
Definition OceanGpuSpectrum.cpp:66
Render-thread-owned GPU projection of immutable spectral coefficients, with no independent clock....
Definition OceanGpuSpectrum.h:65
EVENGINE_API_DOMAINS Result< OceanGpuBandView > band(const OceanGpuFrameToken &token, unsigned index) const
Validate revision and borrow one band for immediate same-device consumption; no allocation.
Definition OceanGpuSpectrum.cpp:251
EVENGINE_API_DOMAINS OceanGpuFrameBuilder frameBuilder(double time)
Prepare a cheap call-only builder; owner must outlive submit().
Definition OceanGpuSpectrum.cpp:138
EVENGINE_API_DOMAINS OceanGpuReadbackBuilder readbackBuilder(const OceanGpuFrameToken &token) const
Prepare explicit diagnostic readback; no readback occurs in normal GPU rendering.
Definition OceanGpuSpectrum.cpp:139
EVENGINE_API_DOMAINS ~OceanGpuSpectrum()
EVENGINE_API_DOMAINS Result< OceanGpuAtlasView > atlas(const OceanGpuFrameToken &token) const
Validate revision and borrow the complete rendering atlas for immediate same-device copying.
Definition OceanGpuSpectrum.cpp:263
Immutable finite sea-state transition; the caller supplies the only simulation clock....
Definition OceanSeaTransition.h:14
Immutable spatial projection at one simulation timestamp, independent of its spectrum owner....
Definition OceanSpectrum.h:61
Immutable initial spectrum; data is shared only with owning frame builders.
Definition OceanSpectrum.h:96
GPGPU module — compute shaders + storage buffers via the active Graphics backend. Uses the graphics q...
Definition Gpgpu.h:23
bool isAvailable() const
True when the active Graphics backend can run compute (device initialized).
Definition Gpgpu.cpp:284
GpuBuffer * newBuffer(int byteSize, const std::string &usage="storage")
Allocate a GPU buffer. usage: "storage" (SSBO) | "staging" (host transfer) | "storage_vertex" (Vulkan...
Definition Gpgpu.cpp:372
Sequence * newSequence()
Create a Kompute-style command Sequence: record buffer transfers and compute dispatches into one comm...
Definition Gpgpu.cpp:384
Definition Graphics.h:134
virtual std::string getBackendName() const =0
Renderer backend id used by sibling modules (e.g. Gpgpu).
std::weak_ptr< const void > resourceLifetime() const
Observe this provider's resource lifetime without extending it.
Definition GraphicsFoliage.cpp:70
Result< eve::Subscription > onResourcesRetiring(std::function< void()> callback) const
Register cleanup before this provider destroys its GPU device/resources.
Definition GraphicsFoliage.cpp:74
@ Complete
EVENGINE_API_WORLD Result< std::unique_ptr< ComputeShader > > createComputeShader(const std::vector< uint32_t > &words)
Create an owning compute pipeline from valid SPIR-V produced by compileComputeSpirv.
Definition Gpgpu.cpp:307
@ InvalidArgument
@ Unsupported
@ Failed
@ StaleHandle
Definition Container.h:602
Call-only borrowed packed float atlas; each four RGBA8 bytes preserve one float's bits....
Definition OceanGpuSpectrum.h:51
std::unique_ptr< gpgpu::GpuBuffer > ping
Definition OceanGpuSpectrum.cpp:35
std::unique_ptr< gpgpu::GpuBuffer > packed
Definition OceanGpuSpectrum.cpp:35
std::unique_ptr< gpgpu::GpuBuffer > pong
Definition OceanGpuSpectrum.cpp:35
std::unique_ptr< gpgpu::GpuBuffer > coefficients
Definition OceanGpuSpectrum.cpp:35
std::uint64_t revision
Definition OceanGpuSpectrum.cpp:45
OceanGpuAtlasView atlasLayout
Definition OceanGpuSpectrum.cpp:44
std::unique_ptr< gpgpu::ComputeShader > fft
Definition OceanGpuSpectrum.cpp:40
std::weak_ptr< const void > lifetime
Definition OceanGpuSpectrum.cpp:39
std::unique_ptr< gpgpu::GpuBuffer > atlas
Definition OceanGpuSpectrum.cpp:43
std::shared_ptr< const OceanSpectrumData > target
Definition OceanGpuSpectrum.cpp:37
std::vector< Band > bands
Definition OceanGpuSpectrum.cpp:42
std::unique_ptr< gpgpu::ComputeShader > pack
Definition OceanGpuSpectrum.cpp:40
std::unique_ptr< gpgpu::Sequence > sequence
Definition OceanGpuSpectrum.cpp:41
Subscription retirement
Definition OceanGpuSpectrum.cpp:48
std::unique_ptr< gpgpu::ComputeShader > evolve
Definition OceanGpuSpectrum.cpp:40
std::shared_ptr< const OceanSpectrumData > data
Definition OceanGpuSpectrum.cpp:37
Owning periodic displacement and particle velocity arrays; index = z * resolution + x.
Definition OceanSpectrum.h:35