| 1 | #include <nn/gfx/detail/gfx_CommandBuffer-api.nvn.8.h> |
| 2 | |
| 3 | #include <nn/gfx/detail/gfx_Buffer-api.nvn.8.h> |
| 4 | #include <nn/gfx/detail/gfx_DescriptorPool-api.nvn.8.h> |
| 5 | #include <nn/gfx/detail/gfx_Device-api.nvn.8.h> |
| 6 | #include <nn/gfx/detail/gfx_MemoryPool-api.nvn.8.h> |
| 7 | #include <nn/gfx/detail/gfx_Pipeline-api.nvn.8.h> |
| 8 | #include <nn/gfx/detail/gfx_RootSignature-api.nvn.8.h> |
| 9 | #include <nn/gfx/detail/gfx_Shader-api.nvn.8.h> |
| 10 | #include <nn/gfx/detail/gfx_State-api.nvn.8.h> |
| 11 | #include <nn/gfx/detail/gfx_Texture-api.nvn.8.h> |
| 12 | #include <nn/gfx/gfx_DescriptorSlot.h> |
| 13 | #include <nn/gfx/gfx_StateInfo.h> |
| 14 | #include <nn/gfx/gfx_TextureInfo.h> |
| 15 | #include <nn/util/util_BytePtr.h> |
| 16 | |
| 17 | #include <algorithm> |
| 18 | |
| 19 | #include "gfx_CommonHelper.h" |
| 20 | #include "gfx_NvnHelper.h" |
| 21 | |
| 22 | namespace nn::gfx::detail { |
| 23 | |
| 24 | namespace { |
| 25 | |
| 26 | template <typename T> |
| 27 | T* ToPtr(const DescriptorSlot& slot) { |
| 28 | return reinterpret_cast<T*>(slot.ToData()->value); |
| 29 | } |
| 30 | |
| 31 | void GetNvnCopyRegion(int* pOffsetY, int* pHeight, int* pOffsetZ, int* pDepth, |
| 32 | const TextureCopyRegion& region, NVNtextureTarget target) { |
| 33 | *pOffsetY = region.GetOffsetV(); |
| 34 | *pHeight = region.GetHeight(); |
| 35 | *pOffsetZ = region.GetOffsetW(); |
| 36 | *pDepth = region.GetDepth(); |
| 37 | |
| 38 | switch (target) { |
| 39 | case NVN_TEXTURE_TARGET_1D_ARRAY: |
| 40 | *pOffsetY = region.GetSubresource().GetArrayIndex(); |
| 41 | *pHeight = std::max(a: region.GetArrayLength(), b: 1); |
| 42 | break; |
| 43 | |
| 44 | case NVN_TEXTURE_TARGET_2D_ARRAY: |
| 45 | case NVN_TEXTURE_TARGET_2D_MULTISAMPLE_ARRAY: |
| 46 | *pOffsetZ = region.GetSubresource().GetArrayIndex(); |
| 47 | *pDepth = std::max(a: region.GetArrayLength(), b: 1); |
| 48 | break; |
| 49 | |
| 50 | default: |
| 51 | break; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | void GetNvnCopyStride(ptrdiff_t* pRowStride, ptrdiff_t* pImageStride, |
| 56 | const BufferTextureCopyRegion& region, NVNtexture* pTexture) { |
| 57 | ptrdiff_t rowStride = 0; |
| 58 | ptrdiff_t imageStride = 0; |
| 59 | |
| 60 | if (region.GetBufferImageWidth() != 0 || region.GetBufferImageHeight() != 0) { |
| 61 | NVNformat nvnFormat = nvnTextureGetFormat(texture: pTexture); |
| 62 | ImageFormat imageFormat = Nvn::GetGfxImageFormat(nvnFormat); |
| 63 | ChannelFormat channelFormat = GetChannelFormat(format: imageFormat); |
| 64 | |
| 65 | int width = |
| 66 | ((region.GetBufferImageWidth() != 0) ? region.GetBufferImageWidth() : |
| 67 | region.GetTextureCopyRegion().GetWidth()); |
| 68 | rowStride = width * GetBytePerPixel(channelFormat); |
| 69 | |
| 70 | if (IsCompressedFormat(channelFormat)) { |
| 71 | rowStride /= GetBlockWidth(channelFormat) * GetBlockHeight(channelFormat); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if (region.GetBufferImageHeight() != 0) { |
| 76 | imageStride = region.GetBufferImageHeight() * rowStride; |
| 77 | } |
| 78 | |
| 79 | *pRowStride = rowStride; |
| 80 | *pImageStride = imageStride; |
| 81 | } |
| 82 | |
| 83 | void SetTextureAndSampler(CommandBufferImpl<ApiVariationNvn8>* pNnCb, ShaderStage stage, int slot, |
| 84 | unsigned int nvnTextureID, unsigned int nvnSamplerID) { |
| 85 | const DeviceImpl<ApiVariationNvn8>* pNnDevice = pNnCb->ToData()->pNnDevice; |
| 86 | NVNtextureHandle textureHandle = |
| 87 | nvnDeviceGetTextureHandle(device: pNnDevice->ToData()->pNvnDevice, textureID: nvnTextureID, samplerID: nvnSamplerID); |
| 88 | |
| 89 | nvnCommandBufferBindTexture(cmdBuf: pNnCb->ToData()->pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), |
| 90 | index: slot, texture: textureHandle); |
| 91 | } |
| 92 | |
| 93 | void CommandBufferMemoryCallbackProcedure([[maybe_unused]] NVNcommandBuffer* pNvnCommandBuffer, |
| 94 | NVNcommandBufferMemoryEvent event, size_t minSize, |
| 95 | void* pCallbackData) { |
| 96 | auto pThis = static_cast<CommandBufferImpl<ApiVariationNvn8>*>(pCallbackData); |
| 97 | CommandBufferImpl<ApiVariationNvn8>::DataType& obj = pThis->ToData(); |
| 98 | |
| 99 | auto pCommandBuffer = reinterpret_cast<TCommandBuffer<ApiVariationNvn8>*>(pThis); |
| 100 | OutOfMemoryEventArg arg{.minRequiredSize: minSize}; |
| 101 | |
| 102 | switch (event) { |
| 103 | case NVN_COMMAND_BUFFER_MEMORY_EVENT_OUT_OF_COMMAND_MEMORY: |
| 104 | reinterpret_cast<CommandBufferImpl<ApiVariationNvn8>::OutOfMemoryEventCallback>( |
| 105 | obj.pOutOfCommandMemoryCallback.ptr)(pCommandBuffer, arg); |
| 106 | break; |
| 107 | |
| 108 | case NVN_COMMAND_BUFFER_MEMORY_EVENT_OUT_OF_CONTROL_MEMORY: |
| 109 | reinterpret_cast<CommandBufferImpl<ApiVariationNvn8>::OutOfMemoryEventCallback>( |
| 110 | obj.pOutOfControlMemoryCallback.ptr)(pCommandBuffer, arg); |
| 111 | break; |
| 112 | |
| 113 | default: |
| 114 | NN_UNEXPECTED_DEFAULT; |
| 115 | break; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | } // namespace |
| 120 | |
| 121 | size_t CommandBufferImpl<ApiVariationNvn8>::GetCommandMemoryAlignment( |
| 122 | DeviceImpl<ApiVariationNvn8>* pDevice) { |
| 123 | int align; |
| 124 | nvnDeviceGetInteger(device: pDevice->ToData()->pNvnDevice, |
| 125 | pname: NVN_DEVICE_INFO_COMMAND_BUFFER_COMMAND_ALIGNMENT, v: &align); |
| 126 | return align; |
| 127 | } |
| 128 | |
| 129 | size_t CommandBufferImpl<ApiVariationNvn8>::GetControlMemoryAlignment( |
| 130 | DeviceImpl<ApiVariationNvn8>* pDevice) { |
| 131 | int align; |
| 132 | nvnDeviceGetInteger(device: pDevice->ToData()->pNvnDevice, |
| 133 | pname: NVN_DEVICE_INFO_COMMAND_BUFFER_CONTROL_ALIGNMENT, v: &align); |
| 134 | return align; |
| 135 | } |
| 136 | |
| 137 | CommandBufferImpl<ApiVariationNvn8>::CommandBufferImpl() { |
| 138 | state = State_NotInitialized; |
| 139 | } |
| 140 | |
| 141 | CommandBufferImpl<ApiVariationNvn8>::~CommandBufferImpl() {} |
| 142 | |
| 143 | void CommandBufferImpl<ApiVariationNvn8>::Initialize(DeviceImpl<ApiVariationNvn8>* pDevice, |
| 144 | [[maybe_unused]] const InfoType& info) { |
| 145 | pNnDevice = pDevice; |
| 146 | NVNdevice* pNvnDevice = pDevice->ToData()->pNvnDevice; |
| 147 | |
| 148 | pNvnCommandBuffer = &nvnCommandBuffer; |
| 149 | |
| 150 | nvnCommandBufferInitialize(cmdBuf: pNvnCommandBuffer, device: pNvnDevice); |
| 151 | |
| 152 | pOutOfCommandMemoryCallback = nullptr; |
| 153 | pOutOfControlMemoryCallback = nullptr; |
| 154 | |
| 155 | nvnCommandBufferSetMemoryCallback(cmdBuf: pNvnCommandBuffer, callback: CommandBufferMemoryCallbackProcedure); |
| 156 | nvnCommandBufferSetMemoryCallbackData(cmdBuf: pNvnCommandBuffer, callbackData: this); |
| 157 | |
| 158 | hNvnCommandBuffer = 0; |
| 159 | |
| 160 | flags.SetBit(p: Flag_ConservativeRasterSupported, on: pDevice->ToData()->supportedFeatures.GetBit( |
| 161 | p: NvnDeviceFeature_SupportConservativeRaster)); |
| 162 | flags.SetBit(p: Flag_Shared, on: false); |
| 163 | |
| 164 | state = State_Initialized; |
| 165 | } |
| 166 | |
| 167 | void CommandBufferImpl<ApiVariationNvn8>::Finalize( |
| 168 | [[maybe_unused]] DeviceImpl<ApiVariationNvn8>* pDevice) { |
| 169 | if (hNvnCommandBuffer != 0) { |
| 170 | nvnDeviceFinalizeCommandHandle(device: pNnDevice->ToData()->pNvnDevice, handles: hNvnCommandBuffer); |
| 171 | hNvnCommandBuffer = 0; |
| 172 | } |
| 173 | |
| 174 | nvnCommandBufferFinalize(cmdBuf: pNvnCommandBuffer); |
| 175 | state = State_NotInitialized; |
| 176 | } |
| 177 | |
| 178 | void CommandBufferImpl<ApiVariationNvn8>::AddCommandMemory(MemoryPoolImpl<ApiVariationNvn8>* pool, |
| 179 | ptrdiff_t ptr, size_t size) { |
| 180 | nvnCommandBufferAddCommandMemory(cmdBuf: pNvnCommandBuffer, pool: pool->ToData()->pNvnMemoryPool, offset: ptr, size); |
| 181 | } |
| 182 | |
| 183 | void CommandBufferImpl<ApiVariationNvn8>::AddControlMemory(void* ptr, size_t size) { |
| 184 | nvnCommandBufferAddControlMemory(cmdBuf: pNvnCommandBuffer, memory: ptr, size); |
| 185 | } |
| 186 | |
| 187 | void CommandBufferImpl<ApiVariationNvn8>::SetOutOfCommandMemoryEventCallback( |
| 188 | OutOfMemoryEventCallback callback) { |
| 189 | pOutOfCommandMemoryCallback = reinterpret_cast<void (*)()>(callback); |
| 190 | } |
| 191 | |
| 192 | void CommandBufferImpl<ApiVariationNvn8>::SetOutOfControlMemoryEventCallback( |
| 193 | OutOfMemoryEventCallback callback) { |
| 194 | pOutOfControlMemoryCallback = reinterpret_cast<void (*)()>(callback); |
| 195 | } |
| 196 | |
| 197 | void CommandBufferImpl<ApiVariationNvn8>::Reset() {} |
| 198 | |
| 199 | void CommandBufferImpl<ApiVariationNvn8>::Begin() { |
| 200 | if (hNvnCommandBuffer != 0) { |
| 201 | nvnDeviceFinalizeCommandHandle(device: pNnDevice->ToData()->pNvnDevice, handles: hNvnCommandBuffer); |
| 202 | hNvnCommandBuffer = 0; |
| 203 | } |
| 204 | |
| 205 | nvnCommandBufferBeginRecording(cmdBuf: pNvnCommandBuffer); |
| 206 | state = State_Begun; |
| 207 | } |
| 208 | |
| 209 | void CommandBufferImpl<ApiVariationNvn8>::End() { |
| 210 | hNvnCommandBuffer = nvnCommandBufferEndRecording(cmdBuf: pNvnCommandBuffer); |
| 211 | state = State_Initialized; |
| 212 | } |
| 213 | |
| 214 | void CommandBufferImpl<ApiVariationNvn8>::Dispatch(int a, int b, int c) { |
| 215 | nvnCommandBufferDispatchCompute(cmdBuf: pNvnCommandBuffer, groupsX: a, groupsY: b, groupsZ: c); |
| 216 | } |
| 217 | |
| 218 | void CommandBufferImpl<ApiVariationNvn8>::Draw(PrimitiveTopology primitiveTopology, int vertexCount, |
| 219 | int vertexOffset) { |
| 220 | nvnCommandBufferDrawArrays(cmdBuf: pNvnCommandBuffer, mode: Nvn::GetDrawPrimitive(primitiveTopology), |
| 221 | first: vertexOffset, count: vertexCount); |
| 222 | } |
| 223 | |
| 224 | void CommandBufferImpl<ApiVariationNvn8>::Draw(PrimitiveTopology primitiveTopology, |
| 225 | int vertexCountPerInstance, int vertexOffset, |
| 226 | int instanceCount, int baseInstance) { |
| 227 | nvnCommandBufferDrawArraysInstanced(cmdBuf: pNvnCommandBuffer, mode: Nvn::GetDrawPrimitive(primitiveTopology), |
| 228 | first: vertexOffset, count: vertexCountPerInstance, baseInstance, |
| 229 | instanceCount); |
| 230 | } |
| 231 | |
| 232 | void CommandBufferImpl<ApiVariationNvn8>::DrawIndexed(PrimitiveTopology primitiveTopology, |
| 233 | IndexFormat indexFormat, |
| 234 | const GpuAddress& indexBufferAddress, |
| 235 | int indexCount, int baseVertex) { |
| 236 | nvnCommandBufferDrawElementsBaseVertex(cmdBuf: pNvnCommandBuffer, |
| 237 | mode: Nvn::GetDrawPrimitive(primitiveTopology), |
| 238 | type: Nvn::GetIndexFormat(indexFormat), count: indexCount, |
| 239 | indexBuffer: Nvn::GetBufferAddress(indexBufferAddress), baseVertex); |
| 240 | } |
| 241 | |
| 242 | void CommandBufferImpl<ApiVariationNvn8>::DrawIndexed(PrimitiveTopology primitiveTopology, |
| 243 | IndexFormat indexFormat, |
| 244 | const GpuAddress& indexBufferAddress, |
| 245 | int indexCountPerInstance, int baseVertex, |
| 246 | int instanceCount, int baseInstance) { |
| 247 | nvnCommandBufferDrawElementsInstanced( |
| 248 | cmdBuf: pNvnCommandBuffer, mode: Nvn::GetDrawPrimitive(primitiveTopology), |
| 249 | type: Nvn::GetIndexFormat(indexFormat), count: indexCountPerInstance, |
| 250 | indexBuffer: Nvn::GetBufferAddress(indexBufferAddress), baseVertex, baseInstance, instanceCount); |
| 251 | } |
| 252 | |
| 253 | void CommandBufferImpl<ApiVariationNvn8>::DispatchIndirect(const GpuAddress& addr) { |
| 254 | nvnCommandBufferDispatchComputeIndirect(cmdBuf: pNvnCommandBuffer, buffer: Nvn::GetBufferAddress(addr)); |
| 255 | } |
| 256 | |
| 257 | void CommandBufferImpl<ApiVariationNvn8>::DrawIndirect(PrimitiveTopology top, |
| 258 | const GpuAddress& addr) { |
| 259 | nvnCommandBufferDrawArraysIndirect(cmdBuf: pNvnCommandBuffer, mode: Nvn::GetDrawPrimitive(top), |
| 260 | buffer: Nvn::GetBufferAddress(addr)); |
| 261 | } |
| 262 | |
| 263 | void CommandBufferImpl<ApiVariationNvn8>::DrawIndexedIndirect(PrimitiveTopology top, |
| 264 | IndexFormat index, |
| 265 | const GpuAddress& addr1, |
| 266 | const GpuAddress& addr2) { |
| 267 | nvnCommandBufferDrawElementsIndirect(cmdBuf: pNvnCommandBuffer, mode: Nvn::GetDrawPrimitive(top), |
| 268 | type: Nvn::GetIndexFormat(index), buffer1: Nvn::GetBufferAddress(addr1), |
| 269 | buffer2: Nvn::GetBufferAddress(addr2)); |
| 270 | } |
| 271 | |
| 272 | void CommandBufferImpl<ApiVariationNvn8>::SetPipeline(const PipelineImpl<ApiVariationNvn8>* pPipe) { |
| 273 | const PipelineImplData<ApiVariationNvn8>& pipe = pPipe->ToData(); |
| 274 | |
| 275 | if (pipe.nnPipelineType == pipe.PipelineType_Graphics) { |
| 276 | SetRasterizerState(nn::gfx::DataToAccessor(data: pipe.nnRasterizerState)); |
| 277 | SetBlendState(nn::gfx::DataToAccessor(data: pipe.nnBlendState)); |
| 278 | SetDepthStencilState(nn::gfx::DataToAccessor(data: pipe.nnDepthStencilState)); |
| 279 | SetVertexState(nn::gfx::DataToAccessor(data: pipe.nnVertexState)); |
| 280 | |
| 281 | if (pipe.flags.GetBit(p: pipe.Flag_HasTessellationState)) { |
| 282 | SetTessellationState(nn::gfx::DataToAccessor(data: pipe.nnTessellationState)); |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | SetShader(pipe.pShader, ShaderStageBit_All); |
| 287 | } |
| 288 | |
| 289 | void CommandBufferImpl<ApiVariationNvn8>::SetRasterizerState( |
| 290 | const RasterizerStateImpl<ApiVariationNvn8>* pRast) { |
| 291 | const RasterizerStateImplData<ApiVariationNvn8>& rast = pRast->ToData(); |
| 292 | |
| 293 | nvnCommandBufferBindPolygonState( |
| 294 | cmdBuf: pNvnCommandBuffer, polygon: reinterpret_cast<const NVNpolygonState*>(&rast.nvnPolygonState)); |
| 295 | nvnCommandBufferSetPolygonOffsetClamp(cmdBuf: pNvnCommandBuffer, factor: rast.nvnSlopeScaledDepthBias, |
| 296 | units: rast.nvnDepthBias, clamp: rast.nvnDepthBiasClamp); |
| 297 | nvnCommandBufferBindMultisampleState( |
| 298 | cmdBuf: pNvnCommandBuffer, multisample: reinterpret_cast<const NVNmultisampleState*>(&rast.nvnMultisampleState)); |
| 299 | |
| 300 | if (rast.flags.GetBit(p: rast.Flag_MultisampleEnabled)) { |
| 301 | nvnCommandBufferSetSampleMask(cmdBuf: pNvnCommandBuffer, mask: rast.nvnSampleMask); |
| 302 | } |
| 303 | |
| 304 | nvnCommandBufferSetDepthClamp(cmdBuf: pNvnCommandBuffer, |
| 305 | clamp: !rast.flags.GetBit(p: rast.Flag_DepthClipEnabled)); |
| 306 | nvnCommandBufferSetRasterizerDiscard(cmdBuf: pNvnCommandBuffer, |
| 307 | discard: !rast.flags.GetBit(p: rast.Flag_RasterEnabled)); |
| 308 | |
| 309 | if (flags.GetBit(p: Flag_ConservativeRasterSupported)) { |
| 310 | nvnCommandBufferSetConservativeRasterEnable( |
| 311 | cmdBuf: pNvnCommandBuffer, enable: rast.flags.GetBit(p: rast.Flag_ConservativeRasterEnabled)); |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | void CommandBufferImpl<ApiVariationNvn8>::SetBlendState( |
| 316 | const BlendStateImpl<ApiVariationNvn8>* pBlendState) { |
| 317 | const BlendStateImplData<ApiVariationNvn8>& blendState = pBlendState->ToData(); |
| 318 | const NVNblendState* pBlendStates = blendState.pNvnBlendStateData; |
| 319 | |
| 320 | for (int i = 0, targetCount = blendState.targetCount; i < targetCount; ++i) { |
| 321 | nvnCommandBufferBindBlendState(cmdBuf: pNvnCommandBuffer, blend: pBlendStates + i); |
| 322 | } |
| 323 | |
| 324 | nvnCommandBufferBindChannelMaskState( |
| 325 | cmdBuf: pNvnCommandBuffer, |
| 326 | channelMask: reinterpret_cast<const NVNchannelMaskState*>(&blendState.nvnChannelMaskState)); |
| 327 | nvnCommandBufferBindColorState( |
| 328 | cmdBuf: pNvnCommandBuffer, color: reinterpret_cast<const NVNcolorState*>(&blendState.nvnColorState)); |
| 329 | nvnCommandBufferSetBlendColor(cmdBuf: pNvnCommandBuffer, blendColor: blendState.nvnBlendConstant); |
| 330 | } |
| 331 | |
| 332 | void CommandBufferImpl<ApiVariationNvn8>::SetDepthStencilState( |
| 333 | const DepthStencilStateImpl<ApiVariationNvn8>* pDepth) { |
| 334 | const DepthStencilStateImplData<ApiVariationNvn8>& depth = pDepth->ToData(); |
| 335 | |
| 336 | nvnCommandBufferBindDepthStencilState( |
| 337 | cmdBuf: pNvnCommandBuffer, |
| 338 | depthStencil: reinterpret_cast<const NVNdepthStencilState*>(depth.nvnDepthStencilState)); |
| 339 | nvnCommandBufferSetStencilValueMask(cmdBuf: pNvnCommandBuffer, faces: NVN_FACE_FRONT_AND_BACK, |
| 340 | mask: depth.nvnStencilValueMask); |
| 341 | nvnCommandBufferSetStencilMask(cmdBuf: pNvnCommandBuffer, faces: NVN_FACE_FRONT_AND_BACK, |
| 342 | mask: depth.nvnStencilMask); |
| 343 | nvnCommandBufferSetStencilRef(cmdBuf: pNvnCommandBuffer, faces: NVN_FACE_BACK, ref: depth.nvnStencilBackRef); |
| 344 | nvnCommandBufferSetStencilRef(cmdBuf: pNvnCommandBuffer, faces: NVN_FACE_FRONT, ref: depth.nvnStencilFrontRef); |
| 345 | |
| 346 | if (!depth.flag.GetBit(p: depth.Flag_DepthBoundsTestEnable)) |
| 347 | nvnCommandBufferSetDepthBounds(cmdBuf: pNvnCommandBuffer, enable: false, n: 0.0f, f: 1.0f); |
| 348 | } |
| 349 | |
| 350 | void CommandBufferImpl<ApiVariationNvn8>::SetVertexState( |
| 351 | const VertexStateImpl<ApiVariationNvn8>* pVert) { |
| 352 | const VertexStateImplData<ApiVariationNvn8>& vert = pVert->ToData(); |
| 353 | |
| 354 | nvnCommandBufferBindVertexAttribState(cmdBuf: pNvnCommandBuffer, numAttribs: vert.vertexAttributeStateCount, |
| 355 | attribs: vert.pNvnVertexAttribState); |
| 356 | nvnCommandBufferBindVertexStreamState(cmdBuf: pNvnCommandBuffer, numStreams: vert.vertexStreamStateCount, |
| 357 | streams: vert.pNvnVertexStreamState); |
| 358 | } |
| 359 | |
| 360 | void CommandBufferImpl<ApiVariationNvn8>::SetTessellationState( |
| 361 | const TessellationStateImpl<ApiVariationNvn8>* pTess) { |
| 362 | const TessellationStateImplData<ApiVariationNvn8>& tess = pTess->ToData(); |
| 363 | |
| 364 | nvnCommandBufferSetPatchSize(cmdBuf: pNvnCommandBuffer, i: tess.patchSize); |
| 365 | } |
| 366 | |
| 367 | void CommandBufferImpl<ApiVariationNvn8>::SetShader(const ShaderImpl<ApiVariationNvn8>* pShader, |
| 368 | int stageBits) { |
| 369 | NVNprogram* pProgram = nullptr; |
| 370 | int shaderStageBits = 0; |
| 371 | |
| 372 | if (pShader) { |
| 373 | pProgram = pShader->ToData()->pNvnProgram; |
| 374 | } |
| 375 | |
| 376 | if (pShader && !pShader->ToData()->flags.GetBit(p: pShader->ToData()->Flag_SeparationEnable)) { |
| 377 | shaderStageBits = pShader->ToData()->nvnShaderStageBits; |
| 378 | } else { |
| 379 | shaderStageBits = Nvn::GetShaderStageBits(stageBits); |
| 380 | } |
| 381 | |
| 382 | nvnCommandBufferBindProgram(cmdBuf: pNvnCommandBuffer, program: pProgram, stages: shaderStageBits); |
| 383 | } |
| 384 | |
| 385 | void CommandBufferImpl<ApiVariationNvn8>::SetRenderTargets( |
| 386 | int colorTargetCount, const ColorTargetViewImpl<ApiVariationNvn8>* const* ppColorTargets, |
| 387 | const DepthStencilViewImpl<ApiVariationNvn8>* pDepthStencil) { |
| 388 | const int MaxRenderTarget = 8; |
| 389 | |
| 390 | NVNtexture* pNvnColorTargets[MaxRenderTarget]; |
| 391 | NVNtextureView* pNvnColorTargetViews[MaxRenderTarget]; |
| 392 | |
| 393 | for (int idxTarget = 0; idxTarget < colorTargetCount; ++idxTarget) { |
| 394 | pNvnColorTargets[idxTarget] = ppColorTargets[idxTarget]->ToData()->pNvnTexture; |
| 395 | pNvnColorTargetViews[idxTarget] = ppColorTargets[idxTarget]->ToData()->pNvnTextureView; |
| 396 | } |
| 397 | |
| 398 | NVNtexture* pDepthTarget = nullptr; |
| 399 | NVNtextureView* pDepthTargetView = nullptr; |
| 400 | |
| 401 | if (pDepthStencil) { |
| 402 | pDepthTarget = pDepthStencil->ToData()->pNvnTexture; |
| 403 | pDepthTargetView = pDepthStencil->ToData()->pNvnTextureView; |
| 404 | } |
| 405 | |
| 406 | nvnCommandBufferSetRenderTargets(cmdBuf: pNvnCommandBuffer, numColors: colorTargetCount, colors: pNvnColorTargets, |
| 407 | colorViews: pNvnColorTargetViews, depthStencil: pDepthTarget, depthStencilView: pDepthTargetView); |
| 408 | } |
| 409 | |
| 410 | void CommandBufferImpl<ApiVariationNvn8>::SetVertexBuffer(int bufferIndex, |
| 411 | const GpuAddress& vertexBuffer, |
| 412 | [[maybe_unused]] ptrdiff_t stride, |
| 413 | size_t size) { |
| 414 | nvnCommandBufferBindVertexBuffer(cmdBuf: pNvnCommandBuffer, index: bufferIndex, |
| 415 | buffer: Nvn::GetBufferAddress(vertexBuffer), size); |
| 416 | } |
| 417 | |
| 418 | void CommandBufferImpl<ApiVariationNvn8>::SetViewportScissorState( |
| 419 | const ViewportScissorStateImpl<ApiVariationNvn8>* pView) { |
| 420 | const ViewportScissorStateImplData<ApiVariationNvn8>& view = pView->ToData(); |
| 421 | |
| 422 | nvnCommandBufferSetDepthRange(cmdBuf: pNvnCommandBuffer, n: view.depthRange[0], f: view.depthRange[1]); |
| 423 | nvnCommandBufferSetViewports(cmdBuf: pNvnCommandBuffer, first: 0, count: 1, ranges: view.viewport); |
| 424 | nvnCommandBufferSetScissors(cmdBuf: pNvnCommandBuffer, first: 0, count: 1, rects: view.scissor); |
| 425 | |
| 426 | int viewportCount = view.viewportCount; |
| 427 | if (viewportCount > 1) { |
| 428 | int = viewportCount - 1; |
| 429 | |
| 430 | nn::util::BytePtr ptr(view.pWorkMemory.ptr); |
| 431 | |
| 432 | auto* viewportArray = ptr.Get<float>(); |
| 433 | auto* depthRangeArray = ptr.Advance(offset: 16 * extraViewportCount).Get<float>(); |
| 434 | auto* scissorArray = ptr.Advance(offset: 8 * extraViewportCount).Get<int32_t>(); |
| 435 | |
| 436 | nvnCommandBufferSetViewports(cmdBuf: pNvnCommandBuffer, first: 1, count: extraViewportCount, ranges: viewportArray); |
| 437 | nvnCommandBufferSetDepthRanges(cmdBuf: pNvnCommandBuffer, first: 1, count: extraViewportCount, ranges: depthRangeArray); |
| 438 | nvnCommandBufferSetScissors(cmdBuf: pNvnCommandBuffer, first: 1, count: extraViewportCount, rects: scissorArray); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | void CommandBufferImpl<ApiVariationNvn8>::CopyBuffer(BufferImpl<ApiVariationNvn8>* pDstBuffer, |
| 443 | ptrdiff_t dstOffset, |
| 444 | const BufferImpl<ApiVariationNvn8>* pSrcBuffer, |
| 445 | ptrdiff_t srcOffset, size_t size) { |
| 446 | NVNbufferAddress src = nvnBufferGetAddress(buffer: pSrcBuffer->ToData()->pNvnBuffer) + srcOffset; |
| 447 | NVNbufferAddress dst = nvnBufferGetAddress(buffer: pDstBuffer->ToData()->pNvnBuffer) + dstOffset; |
| 448 | nvnCommandBufferCopyBufferToBuffer(cmdBuf: pNvnCommandBuffer, src, dst, size, flags: NVN_COPY_FLAGS_NONE); |
| 449 | } |
| 450 | |
| 451 | void CommandBufferImpl<ApiVariationNvn8>::CopyImage( |
| 452 | TextureImpl<ApiVariationNvn8>* pDstTexture, const TextureSubresource& dstSubresource, |
| 453 | int dstOffsetU, int dstOffsetV, int dstOffsetW, |
| 454 | const TextureImpl<ApiVariationNvn8>* pSrcTexture, const TextureCopyRegion& srcCopyRegion) { |
| 455 | NVNtextureTarget target = nvnTextureGetTarget(texture: pSrcTexture->ToData()->pNvnTexture); |
| 456 | |
| 457 | int srcV; |
| 458 | int srcHeight; |
| 459 | int srcW; |
| 460 | int srcDepth; |
| 461 | GetNvnCopyRegion(pOffsetY: &srcV, pHeight: &srcHeight, pOffsetZ: &srcW, pDepth: &srcDepth, region: srcCopyRegion, target); |
| 462 | |
| 463 | NVNcopyRegion srcRegion; |
| 464 | srcRegion.xoffset = srcCopyRegion.GetOffsetU(); |
| 465 | srcRegion.yoffset = srcV; |
| 466 | srcRegion.zoffset = srcW; |
| 467 | srcRegion.width = srcCopyRegion.GetWidth(); |
| 468 | srcRegion.height = srcHeight; |
| 469 | srcRegion.depth = srcDepth; |
| 470 | |
| 471 | NVNcopyRegion dstRegion; |
| 472 | dstRegion.xoffset = dstOffsetU; |
| 473 | dstRegion.yoffset = |
| 474 | (target == NVN_TEXTURE_TARGET_1D_ARRAY) ? dstSubresource.GetArrayIndex() : dstOffsetV; |
| 475 | dstRegion.zoffset = (target == NVN_TEXTURE_TARGET_2D_ARRAY || |
| 476 | target == NVN_TEXTURE_TARGET_2D_MULTISAMPLE_ARRAY) ? |
| 477 | dstSubresource.GetArrayIndex() : |
| 478 | dstOffsetW; |
| 479 | dstRegion.width = srcRegion.width; |
| 480 | dstRegion.height = srcRegion.height; |
| 481 | dstRegion.depth = srcRegion.depth; |
| 482 | |
| 483 | NVNtextureView srcView; |
| 484 | nvnTextureViewSetDefaults(view: &srcView); |
| 485 | nvnTextureViewSetLevels(view: &srcView, baseLevel: srcCopyRegion.GetSubresource().GetMipLevel(), numLevels: 1); |
| 486 | |
| 487 | NVNtextureView dstView; |
| 488 | nvnTextureViewSetDefaults(view: &dstView); |
| 489 | nvnTextureViewSetLevels(view: &dstView, baseLevel: dstSubresource.GetMipLevel(), numLevels: 1); |
| 490 | |
| 491 | nvnCommandBufferCopyTextureToTexture(cmdBuf: pNvnCommandBuffer, srcTexture: pSrcTexture->ToData()->pNvnTexture, |
| 492 | srcView: &srcView, srcRegion: &srcRegion, dstTexture: pDstTexture->ToData()->pNvnTexture, |
| 493 | dstView: &dstView, dstRegion: &dstRegion, flags: NVN_COPY_FLAGS_NONE); |
| 494 | } |
| 495 | |
| 496 | void CommandBufferImpl<ApiVariationNvn8>::CopyBufferToImage( |
| 497 | TextureImpl<ApiVariationNvn8>* pDstTexture, const BufferImpl<ApiVariationNvn8>* pSrcBuffer, |
| 498 | const BufferTextureCopyRegion& copyRegion) { |
| 499 | NVNtextureTarget target = nvnTextureGetTarget(texture: pDstTexture->ToData()->pNvnTexture); |
| 500 | |
| 501 | const TextureCopyRegion& dstRegion = copyRegion.GetTextureCopyRegion(); |
| 502 | |
| 503 | int offsetY; |
| 504 | int height; |
| 505 | int offsetZ; |
| 506 | int depth; |
| 507 | GetNvnCopyRegion(pOffsetY: &offsetY, pHeight: &height, pOffsetZ: &offsetZ, pDepth: &depth, region: dstRegion, target); |
| 508 | |
| 509 | NVNcopyRegion region; |
| 510 | region.xoffset = copyRegion.GetTextureCopyRegion().GetOffsetU(); |
| 511 | region.yoffset = offsetY; |
| 512 | region.zoffset = offsetZ; |
| 513 | region.width = copyRegion.GetTextureCopyRegion().GetWidth(); |
| 514 | region.height = height; |
| 515 | region.depth = depth; |
| 516 | |
| 517 | NVNtextureView view; |
| 518 | nvnTextureViewSetDefaults(view: &view); |
| 519 | nvnTextureViewSetLevels(view: &view, baseLevel: copyRegion.GetTextureCopyRegion().GetSubresource().GetMipLevel(), |
| 520 | numLevels: 1); |
| 521 | |
| 522 | NVNbufferAddress bufferAddress = |
| 523 | nvnBufferGetAddress(buffer: pSrcBuffer->ToData()->pNvnBuffer) + copyRegion.GetBufferOffset(); |
| 524 | |
| 525 | ptrdiff_t rowStride; |
| 526 | ptrdiff_t imageStride; |
| 527 | GetNvnCopyStride(pRowStride: &rowStride, pImageStride: &imageStride, region: copyRegion, pTexture: pDstTexture->ToData()->pNvnTexture); |
| 528 | |
| 529 | nvnCommandBufferSetCopyRowStride(cmdBuf: pNvnCommandBuffer, stride: rowStride); |
| 530 | nvnCommandBufferSetCopyImageStride(cmdBuf: pNvnCommandBuffer, stride: imageStride); |
| 531 | nvnCommandBufferCopyBufferToTexture(cmdBuf: pNvnCommandBuffer, buffer: bufferAddress, |
| 532 | dstTexture: pDstTexture->ToData()->pNvnTexture, dstView: &view, dstRegion: ®ion, |
| 533 | flags: NVN_COPY_FLAGS_NONE); |
| 534 | } |
| 535 | |
| 536 | void CommandBufferImpl<ApiVariationNvn8>::CopyImageToBuffer( |
| 537 | BufferImpl<ApiVariationNvn8>* pDstBuffer, const TextureImpl<ApiVariationNvn8>* pSrcTexture, |
| 538 | const BufferTextureCopyRegion& copyRegion) { |
| 539 | NVNtextureTarget target = nvnTextureGetTarget(texture: pSrcTexture->ToData()->pNvnTexture); |
| 540 | |
| 541 | const TextureCopyRegion& srcRegion = copyRegion.GetTextureCopyRegion(); |
| 542 | |
| 543 | int offsetY; |
| 544 | int height; |
| 545 | int offsetZ; |
| 546 | int depth; |
| 547 | GetNvnCopyRegion(pOffsetY: &offsetY, pHeight: &height, pOffsetZ: &offsetZ, pDepth: &depth, region: srcRegion, target); |
| 548 | |
| 549 | NVNcopyRegion region; |
| 550 | region.xoffset = srcRegion.GetOffsetU(); |
| 551 | region.yoffset = offsetY; |
| 552 | region.zoffset = offsetZ; |
| 553 | region.width = srcRegion.GetWidth(); |
| 554 | region.height = height; |
| 555 | region.depth = depth; |
| 556 | |
| 557 | NVNtextureView view; |
| 558 | nvnTextureViewSetDefaults(view: &view); |
| 559 | nvnTextureViewSetLevels(view: &view, baseLevel: srcRegion.GetSubresource().GetMipLevel(), numLevels: 1); |
| 560 | |
| 561 | NVNbufferAddress bufferAddress = |
| 562 | nvnBufferGetAddress(buffer: pDstBuffer->ToData()->pNvnBuffer) + copyRegion.GetBufferOffset(); |
| 563 | |
| 564 | ptrdiff_t rowStride; |
| 565 | ptrdiff_t imageStride; |
| 566 | GetNvnCopyStride(pRowStride: &rowStride, pImageStride: &imageStride, region: copyRegion, pTexture: pSrcTexture->ToData()->pNvnTexture); |
| 567 | |
| 568 | nvnCommandBufferSetCopyRowStride(cmdBuf: pNvnCommandBuffer, stride: rowStride); |
| 569 | nvnCommandBufferSetCopyImageStride(cmdBuf: pNvnCommandBuffer, stride: imageStride); |
| 570 | nvnCommandBufferCopyTextureToBuffer(cmdBuf: pNvnCommandBuffer, srcTexture: pSrcTexture->ToData()->pNvnTexture, |
| 571 | srcView: &view, srcRegion: ®ion, buffer: bufferAddress, flags: NVN_COPY_FLAGS_NONE); |
| 572 | } |
| 573 | |
| 574 | void CommandBufferImpl<ApiVariationNvn8>::CopyBufferToImage( |
| 575 | TextureImpl<ApiVariationNvn8>* pDstTexture, const TextureCopyRegion& dstRegion, |
| 576 | const BufferImpl<ApiVariationNvn8>* pSrcBuffer, ptrdiff_t srcOffset) { |
| 577 | NVNtextureTarget target = nvnTextureGetTarget(texture: pDstTexture->ToData()->pNvnTexture); |
| 578 | |
| 579 | int offsetY; |
| 580 | int height; |
| 581 | int offsetZ; |
| 582 | int depth; |
| 583 | GetNvnCopyRegion(pOffsetY: &offsetY, pHeight: &height, pOffsetZ: &offsetZ, pDepth: &depth, region: dstRegion, target); |
| 584 | |
| 585 | NVNcopyRegion region; |
| 586 | region.xoffset = dstRegion.GetOffsetU(); |
| 587 | region.yoffset = offsetY; |
| 588 | region.zoffset = offsetZ; |
| 589 | region.width = dstRegion.GetWidth(); |
| 590 | region.height = height; |
| 591 | region.depth = depth; |
| 592 | |
| 593 | NVNtextureView view; |
| 594 | nvnTextureViewSetDefaults(view: &view); |
| 595 | nvnTextureViewSetLevels(view: &view, baseLevel: dstRegion.GetSubresource().GetMipLevel(), numLevels: 1); |
| 596 | |
| 597 | NVNbufferAddress bufferAddress = |
| 598 | nvnBufferGetAddress(buffer: pSrcBuffer->ToData()->pNvnBuffer) + srcOffset; |
| 599 | |
| 600 | nvnCommandBufferSetCopyRowStride(cmdBuf: pNvnCommandBuffer, stride: 0); |
| 601 | nvnCommandBufferSetCopyImageStride(cmdBuf: pNvnCommandBuffer, stride: 0); |
| 602 | nvnCommandBufferCopyBufferToTexture(cmdBuf: pNvnCommandBuffer, buffer: bufferAddress, |
| 603 | dstTexture: pDstTexture->ToData()->pNvnTexture, dstView: &view, dstRegion: ®ion, |
| 604 | flags: NVN_COPY_FLAGS_NONE); |
| 605 | } |
| 606 | |
| 607 | void CommandBufferImpl<ApiVariationNvn8>::CopyImageToBuffer( |
| 608 | BufferImpl<ApiVariationNvn8>* pDstBuffer, ptrdiff_t dstOffset, |
| 609 | const TextureImpl<ApiVariationNvn8>* pSrcTexture, const TextureCopyRegion& srcRegion) { |
| 610 | NVNtextureTarget target = nvnTextureGetTarget(texture: pSrcTexture->ToData()->pNvnTexture); |
| 611 | |
| 612 | int offsetY; |
| 613 | int height; |
| 614 | int offsetZ; |
| 615 | int depth; |
| 616 | GetNvnCopyRegion(pOffsetY: &offsetY, pHeight: &height, pOffsetZ: &offsetZ, pDepth: &depth, region: srcRegion, target); |
| 617 | |
| 618 | NVNcopyRegion region; |
| 619 | region.xoffset = srcRegion.GetOffsetU(); |
| 620 | region.yoffset = offsetY; |
| 621 | region.zoffset = offsetZ; |
| 622 | region.width = srcRegion.GetWidth(); |
| 623 | region.height = height; |
| 624 | region.depth = depth; |
| 625 | |
| 626 | NVNtextureView view; |
| 627 | nvnTextureViewSetDefaults(view: &view); |
| 628 | nvnTextureViewSetLevels(view: &view, baseLevel: srcRegion.GetSubresource().GetMipLevel(), numLevels: 1); |
| 629 | |
| 630 | NVNbufferAddress bufferAddress = |
| 631 | nvnBufferGetAddress(buffer: pDstBuffer->ToData()->pNvnBuffer) + dstOffset; |
| 632 | |
| 633 | nvnCommandBufferSetCopyRowStride(cmdBuf: pNvnCommandBuffer, stride: 0); |
| 634 | nvnCommandBufferSetCopyImageStride(cmdBuf: pNvnCommandBuffer, stride: 0); |
| 635 | nvnCommandBufferCopyTextureToBuffer(cmdBuf: pNvnCommandBuffer, srcTexture: pSrcTexture->ToData()->pNvnTexture, |
| 636 | srcView: &view, srcRegion: ®ion, buffer: bufferAddress, flags: NVN_COPY_FLAGS_NONE); |
| 637 | } |
| 638 | |
| 639 | void CommandBufferImpl<ApiVariationNvn8>::BlitImage( |
| 640 | TextureImpl<ApiVariationNvn8>* pDstTexture, const TextureCopyRegion& dstCopyRegion, |
| 641 | const TextureImpl<ApiVariationNvn8>* pSrcTexture, const TextureCopyRegion& srcCopyRegion, |
| 642 | int copyFlags) { |
| 643 | NVNtextureTarget dstTarget = nvnTextureGetTarget(texture: pDstTexture->ToData()->pNvnTexture); |
| 644 | |
| 645 | int dstV; |
| 646 | int dstHeight; |
| 647 | int dstW; |
| 648 | int dstDepth; |
| 649 | GetNvnCopyRegion(pOffsetY: &dstV, pHeight: &dstHeight, pOffsetZ: &dstW, pDepth: &dstDepth, region: dstCopyRegion, target: dstTarget); |
| 650 | |
| 651 | NVNtextureTarget srcTarget = nvnTextureGetTarget(texture: pSrcTexture->ToData()->pNvnTexture); |
| 652 | |
| 653 | int srcV; |
| 654 | int srcHeight; |
| 655 | int srcW; |
| 656 | int srcDepth; |
| 657 | GetNvnCopyRegion(pOffsetY: &srcV, pHeight: &srcHeight, pOffsetZ: &srcW, pDepth: &srcDepth, region: srcCopyRegion, target: srcTarget); |
| 658 | |
| 659 | NVNcopyRegion dstRegion; |
| 660 | dstRegion.xoffset = dstCopyRegion.GetOffsetU(); |
| 661 | dstRegion.yoffset = dstV; |
| 662 | dstRegion.zoffset = dstW; |
| 663 | dstRegion.width = dstCopyRegion.GetWidth(); |
| 664 | dstRegion.height = dstHeight; |
| 665 | dstRegion.depth = dstDepth; |
| 666 | |
| 667 | NVNcopyRegion srcRegion; |
| 668 | srcRegion.xoffset = srcCopyRegion.GetOffsetU(); |
| 669 | srcRegion.yoffset = srcV; |
| 670 | srcRegion.zoffset = srcW; |
| 671 | srcRegion.width = srcCopyRegion.GetWidth(); |
| 672 | srcRegion.height = srcHeight; |
| 673 | srcRegion.depth = srcDepth; |
| 674 | |
| 675 | NVNtextureView dstView; |
| 676 | nvnTextureViewSetDefaults(view: &dstView); |
| 677 | nvnTextureViewSetLevels(view: &dstView, baseLevel: dstCopyRegion.GetSubresource().GetMipLevel(), numLevels: 1); |
| 678 | |
| 679 | NVNtextureView srcView; |
| 680 | nvnTextureViewSetDefaults(view: &srcView); |
| 681 | nvnTextureViewSetLevels(view: &srcView, baseLevel: srcCopyRegion.GetSubresource().GetMipLevel(), numLevels: 1); |
| 682 | |
| 683 | int nvnCopyFlags = 0; |
| 684 | nvnCopyFlags |= copyFlags & 1; // todo: figure out this conversion? |
| 685 | nvnCommandBufferCopyTextureToTexture(cmdBuf: pNvnCommandBuffer, srcTexture: pSrcTexture->ToData()->pNvnTexture, |
| 686 | srcView: &srcView, srcRegion: &srcRegion, dstTexture: pDstTexture->ToData()->pNvnTexture, |
| 687 | dstView: &dstView, dstRegion: &dstRegion, flags: nvnCopyFlags); |
| 688 | } |
| 689 | |
| 690 | void CommandBufferImpl<ApiVariationNvn8>::ClearBuffer(BufferImpl<ApiVariationNvn8>* pBuffer, |
| 691 | ptrdiff_t offset, size_t size, |
| 692 | uint32_t value) { |
| 693 | NVNbufferAddress bufferAddress = nvnBufferGetAddress(buffer: pBuffer->ToData()->pNvnBuffer) + offset; |
| 694 | nvnCommandBufferClearBuffer(cmdBuf: pNvnCommandBuffer, buffer: bufferAddress, size, i: value); |
| 695 | } |
| 696 | |
| 697 | void CommandBufferImpl<ApiVariationNvn8>::ClearColor( |
| 698 | ColorTargetViewImpl<ApiVariationNvn8>* pColorTarget, float r, float g, float b, float a, |
| 699 | const TextureArrayRange* pArrayRange) { |
| 700 | ClearColorValue clearColor{.valueFloat: {r, g, b, a}}; |
| 701 | ClearColorTarget(pColorTarget, clearColor, pArrayRange); |
| 702 | } |
| 703 | |
| 704 | void CommandBufferImpl<ApiVariationNvn8>::ClearColorTarget( |
| 705 | ColorTargetViewImpl<ApiVariationNvn8>* pColorTarget, const ClearColorValue& clearColor, |
| 706 | const TextureArrayRange* pArrayRange) { |
| 707 | const NVNtexture* const pNvnTexture = pColorTarget->ToData()->pNvnTexture; |
| 708 | const NVNtextureView* const pNvnTextureView = pColorTarget->ToData()->pNvnTextureView; |
| 709 | |
| 710 | NVNcopyRegion region{}; |
| 711 | |
| 712 | int level; |
| 713 | NVNtextureTarget target; |
| 714 | |
| 715 | if (pNvnTextureView) { |
| 716 | int levelCount; |
| 717 | NVNboolean result; |
| 718 | |
| 719 | result = nvnTextureViewGetLevels(view: pNvnTextureView, baseLevel: &level, numLevels: &levelCount); |
| 720 | result = nvnTextureViewGetTarget(view: pNvnTextureView, target: &target); |
| 721 | } else { |
| 722 | level = 0; |
| 723 | target = nvnTextureGetTarget(texture: pNvnTexture); |
| 724 | } |
| 725 | |
| 726 | region.width = nvnTextureGetWidth(texture: pNvnTexture); |
| 727 | region.height = nvnTextureGetHeight(texture: pNvnTexture); |
| 728 | region.depth = nvnTextureGetDepth(texture: pNvnTexture); |
| 729 | |
| 730 | region.width = std::max(a: region.width >> level, b: 1); |
| 731 | if (target != NVN_TEXTURE_TARGET_1D && target != NVN_TEXTURE_TARGET_1D_ARRAY) { |
| 732 | region.height = std::max(a: region.height >> level, b: 1); |
| 733 | if (target == NVN_TEXTURE_TARGET_3D) { |
| 734 | region.depth = std::max(a: region.depth >> level, b: 1); |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | if (pArrayRange) { |
| 739 | if (target == NVN_TEXTURE_TARGET_1D_ARRAY) { |
| 740 | region.yoffset = pArrayRange->GetBaseArrayIndex(); |
| 741 | region.height = pArrayRange->GetArrayLength(); |
| 742 | } else if (target == NVN_TEXTURE_TARGET_2D_ARRAY || |
| 743 | target == NVN_TEXTURE_TARGET_2D_MULTISAMPLE_ARRAY) { |
| 744 | region.zoffset = pArrayRange->GetBaseArrayIndex(); |
| 745 | region.depth = pArrayRange->GetArrayLength(); |
| 746 | } |
| 747 | } |
| 748 | |
| 749 | nvnCommandBufferClearTexture(cmdBuf: pNvnCommandBuffer, dstTexture: pNvnTexture, dstView: pNvnTextureView, dstRegion: ®ion, |
| 750 | color: clearColor.valueFloat, mask: NVN_CLEAR_COLOR_MASK_RGBA); |
| 751 | } |
| 752 | |
| 753 | void CommandBufferImpl<ApiVariationNvn8>::ClearDepthStencil( |
| 754 | DepthStencilViewImpl<ApiVariationNvn8>* pDepthStencil, float depth, int stencil, |
| 755 | DepthStencilClearMode clearMode, [[maybe_unused]] const TextureArrayRange* pArrayRange) { |
| 756 | const NVNtexture* const pNvnTexture = pDepthStencil->ToData()->pNvnTexture; |
| 757 | const NVNtextureView* const pNvnTextureView = pDepthStencil->ToData()->pNvnTextureView; |
| 758 | |
| 759 | nvnCommandBufferSetScissor(cmdBuf: pNvnCommandBuffer, x: 0, y: 0, w: 0x7FFFFFFF, h: 0x7FFFFFFF); |
| 760 | nvnCommandBufferSetRenderTargets(cmdBuf: pNvnCommandBuffer, numColors: 0, colors: nullptr, colorViews: nullptr, depthStencil: pNvnTexture, |
| 761 | depthStencilView: pNvnTextureView); |
| 762 | switch (clearMode) { |
| 763 | case DepthStencilClearMode_Depth: |
| 764 | nvnCommandBufferClearDepthStencil(cmdBuf: pNvnCommandBuffer, depthValue: depth, depthMask: true, stencilValue: stencil, stencilMask: 0); |
| 765 | break; |
| 766 | case DepthStencilClearMode_Stencil: |
| 767 | nvnCommandBufferClearDepthStencil(cmdBuf: pNvnCommandBuffer, depthValue: depth, depthMask: false, stencilValue: stencil, stencilMask: -1); |
| 768 | break; |
| 769 | case DepthStencilClearMode_DepthStencil: |
| 770 | nvnCommandBufferClearDepthStencil(cmdBuf: pNvnCommandBuffer, depthValue: depth, depthMask: true, stencilValue: stencil, stencilMask: -1); |
| 771 | break; |
| 772 | |
| 773 | default: |
| 774 | NN_UNEXPECTED_DEFAULT; |
| 775 | break; |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | void CommandBufferImpl<ApiVariationNvn8>::Resolve( |
| 780 | TextureImpl<ApiVariationNvn8>* pDstTexture, [[maybe_unused]] int dstMipLevel, |
| 781 | [[maybe_unused]] int dstStartArrayIndex, |
| 782 | const ColorTargetViewImpl<ApiVariationNvn8>* pSrcColorTarget, |
| 783 | [[maybe_unused]] const TextureArrayRange* pSrcArrayRange) { |
| 784 | const NVNtexture* pSrcNvnTexture = pSrcColorTarget->ToData()->pNvnTexture; |
| 785 | |
| 786 | nvnCommandBufferDownsample(cmdBuf: pNvnCommandBuffer, src: pSrcNvnTexture, |
| 787 | dst: pDstTexture->ToData()->pNvnTexture); |
| 788 | } |
| 789 | |
| 790 | void CommandBufferImpl<ApiVariationNvn8>::FlushMemory(int gpuAccessFlags) { |
| 791 | int barrier = 0; // const value of 1 in dwarf |
| 792 | barrier |= (gpuAccessFlags & (GpuAccess_Image | GpuAccess_QueryBuffer | GpuAccess_DepthStencil | |
| 793 | GpuAccess_ColorBuffer | GpuAccess_UnorderedAccessBuffer)) ? |
| 794 | NVN_BARRIER_ORDER_PRIMITIVES_BIT : |
| 795 | 0; |
| 796 | if (barrier) { |
| 797 | nvnCommandBufferBarrier(cmdBuf: pNvnCommandBuffer, barrier); |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | void CommandBufferImpl<ApiVariationNvn8>::InvalidateMemory(int gpuAccessFlags) { |
| 802 | int barrier = 0; |
| 803 | |
| 804 | barrier |= |
| 805 | (gpuAccessFlags & (GpuAccess_IndirectBuffer)) ? NVN_BARRIER_ORDER_INDIRECT_DATA_BIT : 0; |
| 806 | |
| 807 | barrier |= (gpuAccessFlags & (GpuAccess_Image | GpuAccess_Texture)) ? |
| 808 | NVN_BARRIER_INVALIDATE_TEXTURE_BIT : |
| 809 | 0; |
| 810 | |
| 811 | barrier |= (gpuAccessFlags & (GpuAccess_ShaderCode | GpuAccess_UnorderedAccessBuffer | |
| 812 | GpuAccess_ConstantBuffer)) ? |
| 813 | NVN_BARRIER_INVALIDATE_SHADER_BIT : |
| 814 | 0; |
| 815 | |
| 816 | barrier |= (gpuAccessFlags & (GpuAccess_Descriptor)) ? |
| 817 | NVN_BARRIER_INVALIDATE_TEXTURE_DESCRIPTOR_BIT : |
| 818 | 0; |
| 819 | |
| 820 | if (barrier) { |
| 821 | nvnCommandBufferBarrier(cmdBuf: pNvnCommandBuffer, barrier); |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | void CommandBufferImpl<ApiVariationNvn8>::CallCommandBuffer( |
| 826 | const CommandBufferImpl<ApiVariationNvn8>* pNestedCommandBuffer) { |
| 827 | NVNcommandHandle nvnCommandHandle = pNestedCommandBuffer->ToData()->hNvnCommandBuffer; |
| 828 | |
| 829 | nvnCommandBufferCallCommands(cmdBuf: pNvnCommandBuffer, numCommands: 1, handles: &nvnCommandHandle); |
| 830 | } |
| 831 | |
| 832 | void CommandBufferImpl<ApiVariationNvn8>::CopyCommandBuffer( |
| 833 | const CommandBufferImpl<ApiVariationNvn8>* pNestedCommandBuffer) { |
| 834 | NVNcommandHandle nvnCommandHandle = pNestedCommandBuffer->ToData()->hNvnCommandBuffer; |
| 835 | |
| 836 | nvnCommandBufferCopyCommands(cmdBuf: pNvnCommandBuffer, numCommands: 1, handles: &nvnCommandHandle); |
| 837 | } |
| 838 | |
| 839 | void CommandBufferImpl<ApiVariationNvn8>::SetBufferStateTransition( |
| 840 | BufferImpl<ApiVariationNvn8>*, int oldState, [[maybe_unused]] int oldStageBits, int newState, |
| 841 | int newStageBits) { |
| 842 | int barrier = 0; |
| 843 | |
| 844 | if ((oldState & (BufferState_QueryBuffer | BufferState_UnorderedAccessBuffer)) || |
| 845 | (newState & (BufferState_QueryBuffer | BufferState_UnorderedAccessBuffer))) { |
| 846 | barrier |= |
| 847 | (newStageBits & (PipelineStageBit_ComputeShader | PipelineStageBit_GeometryShader | |
| 848 | PipelineStageBit_DomainShader | PipelineStageBit_HullShader | |
| 849 | PipelineStageBit_VertexShader | PipelineStageBit_VertexInput)) ? |
| 850 | NVN_BARRIER_ORDER_PRIMITIVES_BIT : |
| 851 | 0; |
| 852 | |
| 853 | barrier |= (newStageBits & (PipelineStageBit_RenderTarget | PipelineStageBit_PixelShader)) ? |
| 854 | NVN_BARRIER_ORDER_FRAGMENTS_BIT : |
| 855 | 0; |
| 856 | |
| 857 | barrier |= |
| 858 | (newState & BufferState_IndirectArgument) ? NVN_BARRIER_ORDER_INDIRECT_DATA_BIT : 0; |
| 859 | } |
| 860 | |
| 861 | barrier |= (newState & (BufferState_UnorderedAccessBuffer | BufferState_ConstantBuffer)) ? |
| 862 | NVN_BARRIER_INVALIDATE_SHADER_BIT : |
| 863 | 0; |
| 864 | |
| 865 | nvnCommandBufferBarrier(cmdBuf: pNvnCommandBuffer, barrier); |
| 866 | } |
| 867 | |
| 868 | void CommandBufferImpl<ApiVariationNvn8>::SetTextureStateTransition( |
| 869 | TextureImpl<ApiVariationNvn8>*, const TextureSubresourceRange*, int oldState, |
| 870 | [[maybe_unused]] int oldStageBits, int newState, int newStageBits) { |
| 871 | int barrier = 0; |
| 872 | |
| 873 | if ((oldState & |
| 874 | (TextureState_DepthWrite | TextureState_ColorTarget | TextureState_ShaderWrite)) || |
| 875 | (newState & |
| 876 | (TextureState_DepthWrite | TextureState_ColorTarget | TextureState_ShaderWrite))) { |
| 877 | barrier |= |
| 878 | (newStageBits & (PipelineStageBit_ComputeShader | PipelineStageBit_GeometryShader | |
| 879 | PipelineStageBit_DomainShader | PipelineStageBit_HullShader | |
| 880 | PipelineStageBit_VertexShader | PipelineStageBit_VertexInput)) ? |
| 881 | NVN_BARRIER_ORDER_PRIMITIVES_BIT : |
| 882 | 0; |
| 883 | |
| 884 | barrier |= (newStageBits & (PipelineStageBit_RenderTarget | PipelineStageBit_PixelShader)) ? |
| 885 | NVN_BARRIER_ORDER_FRAGMENTS_BIT : |
| 886 | 0; |
| 887 | |
| 888 | barrier |= (newState & (TextureState_DepthWrite | TextureState_DepthRead)) ? |
| 889 | NVN_BARRIER_ORDER_PRIMITIVES_BIT : |
| 890 | 0; |
| 891 | } |
| 892 | |
| 893 | barrier |= (newState & (TextureState_ShaderRead)) ? NVN_BARRIER_INVALIDATE_TEXTURE_BIT : 0; |
| 894 | |
| 895 | nvnCommandBufferBarrier(cmdBuf: pNvnCommandBuffer, barrier); |
| 896 | } |
| 897 | |
| 898 | void CommandBufferImpl<ApiVariationNvn8>::SetDescriptorPool( |
| 899 | const DescriptorPoolImpl<ApiVariationNvn8>* pDescriptorPool) { |
| 900 | switch (pDescriptorPool->ToData()->descriptorPoolType) { |
| 901 | case DescriptorPoolType_TextureView: |
| 902 | nvnCommandBufferSetTexturePool(cmdBuf: pNvnCommandBuffer, |
| 903 | pool: pDescriptorPool->ToData()->pDescriptorPool); |
| 904 | break; |
| 905 | case DescriptorPoolType_Sampler: |
| 906 | nvnCommandBufferSetSamplerPool(cmdBuf: pNvnCommandBuffer, |
| 907 | pool: pDescriptorPool->ToData()->pDescriptorPool); |
| 908 | break; |
| 909 | default: |
| 910 | break; |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | void CommandBufferImpl<ApiVariationNvn8>::SetRootSignature( |
| 915 | [[maybe_unused]] PipelineType pipelineType, |
| 916 | RootSignatureImpl<ApiVariationNvn8>* pRootSignature) { |
| 917 | pGfxRootSignature = pRootSignature; |
| 918 | } |
| 919 | |
| 920 | void CommandBufferImpl<ApiVariationNvn8>::SetRootBufferDescriptorTable( |
| 921 | PipelineType pipelineType, int indexDescriptorTable, |
| 922 | const DescriptorSlot& startBufferDescriptorSlot) { |
| 923 | nn::gfx::detail::SetRootBufferDescriptorTable<ApiVariationNvn8>( |
| 924 | pThis: this, pipelineType, indexDescriptorTable, startBufferDescriptorSlot, |
| 925 | descriptorSlotIncrementSize: DescriptorPoolImpl<ApiVariationNvn8>::GetDescriptorSlotIncrementSize( |
| 926 | pNnDevice, DescriptorPoolType_BufferView)); |
| 927 | } |
| 928 | |
| 929 | void CommandBufferImpl<ApiVariationNvn8>::SetRootTextureAndSamplerDescriptorTable( |
| 930 | PipelineType pipelineType, int indexDescriptorTable, |
| 931 | const DescriptorSlot& startTextureDescriptorSlot, |
| 932 | const DescriptorSlot& startSamplerDescriptorSlot) { |
| 933 | nn::gfx::detail::SetRootTextureAndSamplerDescriptorTable( |
| 934 | pThis: this, pipelineType, indexDescriptorTable, startTextureDescriptorSlot, |
| 935 | startSamplerDescriptorSlot, |
| 936 | textureDescriptorSlotIncrementSize: DescriptorPoolImpl<ApiVariationNvn8>::GetDescriptorSlotIncrementSize( |
| 937 | pNnDevice, DescriptorPoolType_TextureView), |
| 938 | samplerDescriptorSlotIncrementSize: DescriptorPoolImpl<ApiVariationNvn8>::GetDescriptorSlotIncrementSize( |
| 939 | pNnDevice, DescriptorPoolType_Sampler)); |
| 940 | } |
| 941 | |
| 942 | void CommandBufferImpl<ApiVariationNvn8>::SetRootConstantBuffer( |
| 943 | PipelineType pipelineType, int indexDynamicDescriptor, const GpuAddress& constantBufferAddress, |
| 944 | size_t size) { |
| 945 | nn::gfx::detail::SetRootConstantBuffer(pThis: this, pipelineType, indexDynamicDescriptor, |
| 946 | constantBufferAddress, size); |
| 947 | } |
| 948 | |
| 949 | void CommandBufferImpl<ApiVariationNvn8>::SetRootUnorderedAccessBuffer( |
| 950 | PipelineType pipelineType, int indexDynamicDescriptor, |
| 951 | const GpuAddress& unorderedAccessBufferAddress, size_t size) { |
| 952 | nn::gfx::detail::SetRootUnorderedAccessBuffer(pThis: this, pipelineType, indexDynamicDescriptor, |
| 953 | unorderedAccessBufferAddress, size); |
| 954 | } |
| 955 | |
| 956 | void CommandBufferImpl<ApiVariationNvn8>::SetRootTextureAndSampler( |
| 957 | PipelineType pipelineType, int indexDynamicDescriptor, |
| 958 | const TextureViewImpl<ApiVariationNvn8>* pTextureView, |
| 959 | const SamplerImpl<ApiVariationNvn8>* pSampler) { |
| 960 | nn::gfx::detail::SetRootTextureAndSampler(pThis: this, pipelineType, indexDynamicDescriptor, |
| 961 | pTextureView, pSampler); |
| 962 | } |
| 963 | |
| 964 | void CommandBufferImpl<ApiVariationNvn8>::BeginQuery(QueryTarget target) { |
| 965 | if (target != QueryTarget_ComputeShaderInvocations) { |
| 966 | NVNcounterType counterType = Nvn::GetCounterType(target); |
| 967 | nvnCommandBufferResetCounter(cmdBuf: pNvnCommandBuffer, counter: counterType); |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | void CommandBufferImpl<ApiVariationNvn8>::EndQuery(const GpuAddress& dstBufferAddress, |
| 972 | QueryTarget target) { |
| 973 | if (target != QueryTarget_ComputeShaderInvocations) { |
| 974 | NVNcounterType counterType = Nvn::GetCounterType(target); |
| 975 | nvnCommandBufferReportCounter(cmdBuf: pNvnCommandBuffer, counter: counterType, |
| 976 | buffer: Nvn::GetBufferAddress(dstBufferAddress)); |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | void CommandBufferImpl<ApiVariationNvn8>::WriteTimestamp(const GpuAddress& dstBufferAddress) { |
| 981 | nvnCommandBufferReportCounter(cmdBuf: pNvnCommandBuffer, counter: NVN_COUNTER_TYPE_TIMESTAMP, |
| 982 | buffer: Nvn::GetBufferAddress(dstBufferAddress)); |
| 983 | } |
| 984 | |
| 985 | void CommandBufferImpl<ApiVariationNvn8>::SetDepthBounds(float minDepthBounds, |
| 986 | float maxDepthBounds) { |
| 987 | nvnCommandBufferSetDepthBounds(cmdBuf: pNvnCommandBuffer, enable: true, n: minDepthBounds, f: maxDepthBounds); |
| 988 | } |
| 989 | |
| 990 | void CommandBufferImpl<ApiVariationNvn8>::SetLineWidth(float lineWidth) { |
| 991 | nvnCommandBufferSetLineWidth(cmdBuf: pNvnCommandBuffer, lineWidth); |
| 992 | } |
| 993 | |
| 994 | void CommandBufferImpl<ApiVariationNvn8>::SetViewports(int firstViewport, int viewportCount, |
| 995 | const ViewportStateInfo* pViewports) { |
| 996 | const int maxViewports = 16; |
| 997 | |
| 998 | float viewports[maxViewports * 4]; |
| 999 | float depthRanges[maxViewports * 2]; |
| 1000 | float* pViewport = viewports; |
| 1001 | float* pDepthRange = depthRanges; |
| 1002 | |
| 1003 | for (int idxViewport = 0; idxViewport < viewportCount; ++idxViewport) { |
| 1004 | const ViewportStateInfo& viewport = pViewports[idxViewport]; |
| 1005 | |
| 1006 | *pViewport++ = viewport.GetOriginX(); |
| 1007 | *pViewport++ = viewport.GetOriginY(); |
| 1008 | *pViewport++ = viewport.GetWidth(); |
| 1009 | *pViewport++ = viewport.GetHeight(); |
| 1010 | *pDepthRange++ = viewport.GetMinDepth(); |
| 1011 | *pDepthRange++ = viewport.GetMaxDepth(); |
| 1012 | } |
| 1013 | |
| 1014 | nvnCommandBufferSetViewports(cmdBuf: pNvnCommandBuffer, first: firstViewport, count: viewportCount, ranges: viewports); |
| 1015 | nvnCommandBufferSetDepthRanges(cmdBuf: pNvnCommandBuffer, first: firstViewport, count: viewportCount, ranges: depthRanges); |
| 1016 | } |
| 1017 | |
| 1018 | void CommandBufferImpl<ApiVariationNvn8>::SetScissors(int firstScissor, int scissorCount, |
| 1019 | const ScissorStateInfo* pScissors) { |
| 1020 | const int maxScissors = 16; |
| 1021 | |
| 1022 | int scissors[maxScissors * 4]; |
| 1023 | int* pScissor = scissors; |
| 1024 | |
| 1025 | for (int idxScissor = 0; idxScissor < scissorCount; ++idxScissor) { |
| 1026 | const ScissorStateInfo& scissor = pScissors[idxScissor]; |
| 1027 | |
| 1028 | *pScissor++ = scissor.GetOriginX(); |
| 1029 | *pScissor++ = scissor.GetOriginY(); |
| 1030 | *pScissor++ = scissor.GetWidth(); |
| 1031 | *pScissor++ = scissor.GetHeight(); |
| 1032 | } |
| 1033 | |
| 1034 | nvnCommandBufferSetScissors(cmdBuf: pNvnCommandBuffer, first: firstScissor, count: scissorCount, rects: scissors); |
| 1035 | } |
| 1036 | |
| 1037 | void CommandBufferImpl<ApiVariationNvn8>::SetConstantBuffer( |
| 1038 | int slot, ShaderStage stage, const DescriptorSlot& constantBufferDescriptor) { |
| 1039 | nn::util::ConstBytePtr pDescriptor(ToPtr<void*>(slot: constantBufferDescriptor)); |
| 1040 | NVNbufferAddress address = *pDescriptor.Get<NVNbufferAddress>(); |
| 1041 | size_t size = *pDescriptor.Advance(offset: 8).Get<size_t>(); |
| 1042 | |
| 1043 | nvnCommandBufferBindUniformBuffer(cmdBuf: pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), index: slot, buffer: address, |
| 1044 | size); |
| 1045 | } |
| 1046 | |
| 1047 | void CommandBufferImpl<ApiVariationNvn8>::SetUnorderedAccessBuffer( |
| 1048 | int slot, ShaderStage stage, const DescriptorSlot& unorderedAccessBufferDescriptor) { |
| 1049 | nn::util::ConstBytePtr pDescriptor(ToPtr<void*>(slot: unorderedAccessBufferDescriptor)); |
| 1050 | NVNbufferAddress address = *pDescriptor.Get<NVNbufferAddress>(); |
| 1051 | size_t size = *pDescriptor.Advance(offset: 8).Get<size_t>(); |
| 1052 | |
| 1053 | nvnCommandBufferBindStorageBuffer(cmdBuf: pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), index: slot, buffer: address, |
| 1054 | size); |
| 1055 | } |
| 1056 | |
| 1057 | void CommandBufferImpl<ApiVariationNvn8>::SetTextureAndSampler( |
| 1058 | int slot, ShaderStage stage, const DescriptorSlot& textureDescriptor, |
| 1059 | const DescriptorSlot& samplerDescriptor) { |
| 1060 | detail::SetTextureAndSampler(pNnCb: this, stage, slot, nvnTextureID: textureDescriptor.ToData()->value, |
| 1061 | nvnSamplerID: samplerDescriptor.ToData()->value); |
| 1062 | } |
| 1063 | |
| 1064 | void CommandBufferImpl<ApiVariationNvn8>::SetTexture(int slot, ShaderStage stage, |
| 1065 | const DescriptorSlot& textureDescriptor) { |
| 1066 | NVNtextureHandle textureHandle = nvnDeviceGetTexelFetchHandle( |
| 1067 | device: pNnDevice->ToData()->pNvnDevice, textureID: textureDescriptor.ToData()->value); |
| 1068 | |
| 1069 | nvnCommandBufferBindTexture(cmdBuf: pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), index: slot, texture: textureHandle); |
| 1070 | } |
| 1071 | |
| 1072 | void CommandBufferImpl<ApiVariationNvn8>::SetImage(int slot, ShaderStage stage, |
| 1073 | const DescriptorSlot& imageDescriptor) { |
| 1074 | NVNtextureHandle imageHandle = |
| 1075 | nvnDeviceGetImageHandle(device: pNnDevice->ToData()->pNvnDevice, textureID: imageDescriptor.ToData()->value); |
| 1076 | |
| 1077 | nvnCommandBufferBindImage(cmdBuf: pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), index: slot, image: imageHandle); |
| 1078 | } |
| 1079 | |
| 1080 | void CommandBufferImpl<ApiVariationNvn8>::SetConstantBuffer(int slot, ShaderStage stage, |
| 1081 | const GpuAddress& constantBufferAddress, |
| 1082 | size_t size) { |
| 1083 | nvnCommandBufferBindUniformBuffer(cmdBuf: pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), index: slot, |
| 1084 | buffer: Nvn::GetBufferAddress(constantBufferAddress), size); |
| 1085 | } |
| 1086 | |
| 1087 | void CommandBufferImpl<ApiVariationNvn8>::SetUnorderedAccessBuffer( |
| 1088 | int slot, ShaderStage stage, const GpuAddress& unorderedAccessBufferAddress, size_t size) { |
| 1089 | nvnCommandBufferBindStorageBuffer(cmdBuf: pNvnCommandBuffer, stage: Nvn::GetShaderStage(stage), index: slot, |
| 1090 | buffer: Nvn::GetBufferAddress(unorderedAccessBufferAddress), size); |
| 1091 | } |
| 1092 | |
| 1093 | void CommandBufferImpl<ApiVariationNvn8>::SetTextureAndSampler( |
| 1094 | int, ShaderStage, const TextureViewImpl<ApiVariationNvn8>*, |
| 1095 | const SamplerImpl<ApiVariationNvn8>*) {} |
| 1096 | |
| 1097 | void CommandBufferImpl<ApiVariationNvn8>::SetImage(int, ShaderStage, |
| 1098 | const TextureViewImpl<ApiVariationNvn8>*) {} |
| 1099 | |
| 1100 | } // namespace nn::gfx::detail |