|
| 1 | +from .common cimport OptixResult, CUstream, CUdeviceptr |
| 2 | +from .context cimport OptixDeviceContext, OptixContextObject |
| 3 | +from libcpp.vector cimport vector |
| 4 | +from .base cimport OptixObject |
| 5 | +from libc.stdint cimport uintptr_t |
| 6 | + |
| 7 | +cdef extern from "optix_includes.h" nogil: |
| 8 | + cdef enum OptixDenoiserModelKind: |
| 9 | + OPTIX_DENOISER_MODEL_KIND_LDR |
| 10 | + OPTIX_DENOISER_MODEL_KIND_HDR |
| 11 | + OPTIX_DENOISER_MODEL_KIND_AOV |
| 12 | + OPTIX_DENOISER_MODEL_KIND_TEMPORAL |
| 13 | + OPTIX_DENOISER_MODEL_KIND_TEMPORAL_AOV |
| 14 | + |
| 15 | + |
| 16 | + cdef struct OptixDenoiserOptions: |
| 17 | + unsigned int guideAlbedo |
| 18 | + unsigned int guideNormal |
| 19 | + |
| 20 | + cdef struct OptixDenoiserSizes: |
| 21 | + size_t stateSizeInBytes |
| 22 | + size_t withOverlapScratchSizeInBytes |
| 23 | + size_t withoutOverlapScratchSizeInBytes |
| 24 | + unsigned int overlapWindowSizeInPixels |
| 25 | + |
| 26 | + cdef struct OptixDenoiserParams: |
| 27 | + unsigned int denoiseAlpha |
| 28 | + CUdeviceptr hdrIntensity |
| 29 | + float blendFactor |
| 30 | + CUdeviceptr hdrAverageColor |
| 31 | + |
| 32 | + cdef enum OptixPixelFormat: |
| 33 | + OPTIX_PIXEL_FORMAT_HALF2 |
| 34 | + OPTIX_PIXEL_FORMAT_HALF3 |
| 35 | + OPTIX_PIXEL_FORMAT_HALF4 |
| 36 | + OPTIX_PIXEL_FORMAT_FLOAT2 |
| 37 | + OPTIX_PIXEL_FORMAT_FLOAT3 |
| 38 | + OPTIX_PIXEL_FORMAT_FLOAT4 |
| 39 | + OPTIX_PIXEL_FORMAT_UCHAR3 |
| 40 | + OPTIX_PIXEL_FORMAT_UCHAR4 |
| 41 | + |
| 42 | + cdef struct OptixImage2D: |
| 43 | + CUdeviceptr data |
| 44 | + unsigned int width |
| 45 | + unsigned int height |
| 46 | + unsigned int rowStrideInBytes |
| 47 | + unsigned int pixelStrideInBytes |
| 48 | + OptixPixelFormat format |
| 49 | + |
| 50 | + cdef struct OptixDenoiserLayer: |
| 51 | + OptixImage2D input |
| 52 | + OptixImage2D previousOutput |
| 53 | + OptixImage2D output |
| 54 | + |
| 55 | + cdef struct OptixDenoiserGuideLayer: |
| 56 | + OptixImage2D albedo |
| 57 | + OptixImage2D normal |
| 58 | + OptixImage2D flow |
| 59 | + |
| 60 | + ctypedef uintptr_t OptixDenoiser |
| 61 | + |
| 62 | + OptixResult optixDenoiserCreate(OptixDeviceContext context, |
| 63 | + OptixDenoiserModelKind modelKind, |
| 64 | + const OptixDenoiserOptions* options, |
| 65 | + OptixDenoiser* denoiser |
| 66 | + ) |
| 67 | + |
| 68 | + OptixResult optixDenoiserCreateWithUserModel(OptixDeviceContext context, |
| 69 | + const void* userData, |
| 70 | + size_t userDataSizeInBytes, |
| 71 | + OptixDenoiser* denoiser |
| 72 | + ) |
| 73 | + |
| 74 | + OptixResult optixDenoiserDestroy(OptixDenoiser denoiser) |
| 75 | + |
| 76 | + OptixResult optixDenoiserComputeMemoryResources(const OptixDenoiser denoiser, |
| 77 | + unsigned int inputWidth, |
| 78 | + unsigned int inputHeight, |
| 79 | + OptixDenoiserSizes* returnSizes) |
| 80 | + |
| 81 | + OptixResult optixDenoiserSetup( |
| 82 | + OptixDenoiser denoiser, |
| 83 | + CUstream stream, |
| 84 | + unsigned int inputWidth, |
| 85 | + unsigned int inputHeight, |
| 86 | + CUdeviceptr denoiserState, |
| 87 | + size_t denoiserStateSizeInBytes, |
| 88 | + CUdeviceptr scratch, |
| 89 | + size_t scratchSizeInBytes) |
| 90 | + |
| 91 | + OptixResult optixDenoiserInvoke( |
| 92 | + OptixDenoiser denoiser, |
| 93 | + CUstream stream, |
| 94 | + const OptixDenoiserParams * params, |
| 95 | + CUdeviceptr denoiserState, |
| 96 | + size_t denoiserStateSizeInBytes, |
| 97 | + const OptixDenoiserGuideLayer * guideLayer, |
| 98 | + const OptixDenoiserLayer * layers, |
| 99 | + unsigned int numLayers, |
| 100 | + unsigned int inputOffsetX, |
| 101 | + unsigned int inputOffsetY, |
| 102 | + CUdeviceptr scratch, |
| 103 | + size_t scratchSizeInBytes) |
| 104 | + |
| 105 | + OptixResult optixDenoiserComputeAverageColor( |
| 106 | + OptixDenoiser denoiser, |
| 107 | + CUstream stream, |
| 108 | + const OptixImage2D * inputImage, |
| 109 | + CUdeviceptr outputAverageColor, |
| 110 | + CUdeviceptr scratch, |
| 111 | + size_t scratchSizeInBytes) |
| 112 | + |
| 113 | + OptixResult optixDenoiserComputeIntensity( |
| 114 | + OptixDenoiser denoiser, |
| 115 | + CUstream stream, |
| 116 | + const OptixImage2D * inputImage, |
| 117 | + CUdeviceptr outputIntensity, |
| 118 | + CUdeviceptr scratch, |
| 119 | + size_t scratchSizeInBytes) |
| 120 | + |
| 121 | + |
| 122 | +class Image2D(OptixObject): |
| 123 | + cdef OptixImage2D image |
| 124 | + cdef object _d_data |
| 125 | + |
| 126 | +class DenoiserLayer(OptixObject): |
| 127 | + cdef OptixDenoiserLayer layer |
| 128 | + cdef Image2D input |
| 129 | + cdef Image2D previous_output |
| 130 | + cdef Image2D output |
| 131 | + |
| 132 | +class Denoiser(OptixContextObject): |
| 133 | + cdef OptixDenoiser denoiser |
| 134 | + cdef bool guide_albedo |
| 135 | + cdef bool guide_normals |
0 commit comments