| 689 | } |
| 690 | |
| 691 | static bool ValidateBufferUploadDesc(DeviceVal& device, uint32_t i, const BufferUploadDesc& bufferUploadDesc) { |
| 692 | if (bufferUploadDesc.dataSize == 0) { |
| 693 | REPORT_WARNING(&device, "'bufferUploadDescs[%u].dataSize' is 0 (nothing to upload)", i); |
| 694 | return true; |
| 695 | } |
| 696 | |
| 697 | const BufferVal& bufferVal = *(BufferVal*)bufferUploadDesc.buffer; |
| 698 | const uint64_t rangeEnd = bufferUploadDesc.bufferOffset + bufferUploadDesc.dataSize; |
| 699 | |
| 700 | RETURN_ON_FAILURE(&device, bufferUploadDesc.buffer != nullptr, false, "'bufferUploadDescs[%u].buffer' is invalid", i); |
| 701 | RETURN_ON_FAILURE(&device, bufferUploadDesc.data != nullptr, false, "'bufferUploadDescs[%u].data' is invalid", i); |
| 702 | RETURN_ON_FAILURE(&device, bufferVal.IsBoundToMemory(), false, "'bufferUploadDescs[%u].buffer' is not bound to memory", i); |
| 703 | RETURN_ON_FAILURE(&device, rangeEnd <= bufferVal.GetDesc().size, false, "'bufferUploadDescs[%u].bufferOffset + bufferUploadDescs[%u].dataSize' is out of bounds", i, i); |
| 704 | |
| 705 | return true; |
| 706 | } |
| 707 | |
| 708 | static Result NRI_CALL UploadData(Queue& queue, const TextureUploadDesc* textureUploadDescs, uint32_t textureUploadDescNum, const BufferUploadDesc* bufferUploadDescs, uint32_t bufferUploadDescNum) { |
| 709 | QueueVal& queueVal = (QueueVal&)queue; |
no test coverage detected