Files
DoomRTX/neo/engine/opengl/opengl_nn.h
T
Justin Marshall 1c1f828271 Added nn trainer.
2026-05-18 07:33:20 -07:00

87 lines
3.0 KiB
C

#pragma once
// -----------------------------------------------------------------------------
// Shim entry points supplied by gl_d3d12shim.cpp.
// These have C++ linkage in the shim source, so do not wrap them in extern "C".
// -----------------------------------------------------------------------------
extern ID3D12Device* QD3D12_GetDevice(void);
extern ID3D12CommandQueue* QD3D12_GetQueue(void);
extern void QD3D12_WaitForGPU_External(void);
#ifndef QD3D12_NEURAL_POM_API
#define QD3D12_NEURAL_POM_API
#endif
#ifndef QD3D12_NEURAL_POM_MAX_PATH_CHARS
#define QD3D12_NEURAL_POM_MAX_PATH_CHARS 520
#endif
#define QD3D12_NEURAL_POM_TRAIN_FLAG_NONE 0u
#define QD3D12_NEURAL_POM_TRAIN_FLAG_VERBOSE 1u
#define QD3D12_NEURAL_POM_TRAIN_FLAG_RESERVED_FORCE_CPU 2u
#define QD3D12_NEURAL_POM_TRAIN_FLAG_RESERVED_ALLOW_FALLBACK 4u
typedef void(__cdecl* QD3D12NeuralPOMProgressCallback)(
const char* message,
uint32_t currentSample,
uint32_t totalSamples,
float meanLoss,
void* userData);
struct QD3D12NeuralPOMImageRGBA8
{
uint32_t width;
uint32_t height;
uint32_t rowPitchBytes;
const void* pixelsRGBA8;
};
struct QD3D12NeuralPOMTrainDesc
{
uint32_t size;
// File path path. Used when the matching image pointer below is null.
const char* albedoPath;
const char* normalPath;
const char* specularPath; // null, empty, or "-" means no authored specular.
char outputPrefix[512];
// Optional direct image data path. This is the recommended path when calling
// from gl_d3d12shim.cpp because TextureResource::sysmem is already RGBA8.
const QD3D12NeuralPOMImageRGBA8* albedoImage;
const QD3D12NeuralPOMImageRGBA8* normalImage;
const QD3D12NeuralPOMImageRGBA8* specularImage;
uint32_t samples; // default 300000
uint32_t samplesPerGpuBatch; // default 8192
uint32_t latentResolution; // default 128
uint32_t latentChannels; // default 8
uint32_t hiddenCount; // default 48
uint32_t randomSeed; // default 0xC001D00D
uint32_t flags;
float normalStrength; // default 1.0, clamped 0..4
float normalMapYSign; // default +1, use -1 if your normal map green channel is inverted
QD3D12NeuralPOMProgressCallback progress;
void* progressUserData;
};
struct QD3D12NeuralPOMTrainStats
{
uint32_t size;
uint32_t samplesTrained;
uint32_t gpuBatches;
float finalMeanLoss;
char manifestPath[QD3D12_NEURAL_POM_MAX_PATH_CHARS];
char weightsPath[QD3D12_NEURAL_POM_MAX_PATH_CHARS];
char latentF32Path[QD3D12_NEURAL_POM_MAX_PATH_CHARS];
char latentRGBA16FPath[QD3D12_NEURAL_POM_MAX_PATH_CHARS];
char error[1024];
};
QD3D12_NEURAL_POM_API int QD3D12_NeuralPOMTrainMaterialD3D12(
const QD3D12NeuralPOMTrainDesc* desc,
QD3D12NeuralPOMTrainStats* stats);
void APIENTRY glNeuralPOMMaterialQD3D12(GLuint texture, GLsizei weightsBytes, const GLvoid* weightsData, GLsizei latentBytes, const GLvoid* latentRGBA16FData);
void APIENTRY glBindNeuralPOMTextureQD3D12(GLuint texture);