summaryrefslogtreecommitdiffstats
path: root/Python/_sqlite3.pyd
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-10-30 15:06:46 -0700
committeryum <yum.food.vr@gmail.com>2022-10-30 15:06:46 -0700
commit20cfb71f92de56768dba44193032e835ae1e527f (patch)
tree40097dec4a3ee2b2a82527aa54e62812823377fa /Python/_sqlite3.pyd
parentcd4ef446d309a4666037c019dc461933d2f8ca7a (diff)
Reduce total # of select bits from 44 to 4
The board is divided into 16 regions. We select the region to be updated by updating 4 boolean parameters. We *used* to define 4 parameters per layer. Now we just have 4 params total, which affect every layer. Total param memory: 142 bits -> 102 bits Params updated per region update: 56 -> 16
Diffstat (limited to 'Python/_sqlite3.pyd')
0 files changed, 0 insertions, 0 deletions
'>113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
// main.cpp

// This file implements an example of hardware ray-tracing using
// Slang shaders and the `gfx` graphics API.

#include "core/slang-basic.h"
#include "examples/example-base/example-base.h"
#include "gfx-util/shader-cursor.h"
#include "platform/vector-math.h"
#include "platform/window.h"
#include "slang-com-ptr.h"
#include "slang-gfx.h"
#include "slang.h"

using namespace gfx;
using namespace Slang;

static const ExampleResources resourceBase("ray-tracing-pipeline");

struct Uniforms
{
    float screenWidth, screenHeight;
    float focalLength = 24.0f, frameHeight = 24.0f;
    float cameraDir[4];
    float cameraUp[4];
    float cameraRight[4];
    float cameraPosition[4];
    float lightDir[4];
};

struct Vertex
{
    float position[3];
};

// Define geometry data for our test scene.
// The scene contains a floor plane, and a cube placed on top of it at the center.
static const int kVertexCount = 24;
static const Vertex kVertexData[kVertexCount] = {
    // Floor plane
    {{-100.0f, 0, 100.0f}},
    {{100.0f, 0, 100.0f}},
    {{100.0f, 0, -100.0f}},
    {{-100.0f, 0, -100.0f}},
    // Cube face (+y).
    {{-1.0f, 2.0, 1.0f}},
    {{1.0f, 2.0, 1.0f}},
    {{1.0f, 2.0, -1.0f}},
    {{-1.0f, 2.0, -1.0f}},
    // Cube face (+z).
    {{-1.0f, 0.0, 1.0f}},
    {{1.0f, 0.0, 1.0f}},
    {{1.0f, 2.0, 1.0f}},
    {{-1.0f, 2.0, 1.0f}},
    // Cube face (-z).
    {{-1.0f, 0.0, -1.0f}},
    {{-1.0f, 2.0, -1.0f}},
    {{1.0f, 2.0, -1.0f}},
    {{1.0f, 0.0, -1.0f}},
    // Cube face (-x).
    {{-1.0f, 0.0, -1.0f}},
    {{-1.0f, 0.0, 1.0f}},
    {{-1.0f, 2.0, 1.0f}},
    {{-1.0f, 2.0, -1.0f}},
    // Cube face (+x).
    {{1.0f, 2.0, -1.0f}},
    {{1.0f, 2.0, 1.0f}},
    {{1.0f, 0.0, 1.0f}},
    {{1.0f, 0.0, -1.0f}},
};
static const int kIndexCount = 36;
static const int kIndexData[kIndexCount] = {0,  1,  2,  0,  2,  3,  4,  5,  6,  4,  6,  7,
                                            8,  9,  10, 8,  10, 11, 12, 13, 14, 12, 14, 15,
                                            16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23};

struct Primitive
{
    float data[4];
    float color[4];
};
static const int kPrimitiveCount = 12;
static const Primitive kPrimitiveData[kPrimitiveCount] = {
    {{0.0f, 1.0f, 0.0f, 0.0f}, {0.75f, 0.8f, 0.85f, 1.0f}},
    {{0.0f, 1.0f, 0.0f, 0.0f}, {0.75f, 0.8f, 0.85f, 1.0f}},
    {{0.0f, 1.0f, 0.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{0.0f, 1.0f, 0.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{0.0f, 0.0f, 1.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{0.0f, 0.0f, 1.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{0.0f, 0.0f, -1.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{0.0f, 0.0f, -1.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{-1.0f, 0.0f, 0.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{-1.0f, 0.0f, 0.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{1.0f, 0.0f, 0.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
    {{1.0f, 0.0f, 0.0f, 0.0f}, {0.95f, 0.85f, 0.05f, 1.0f}},
};


// We need to use a rasterization pipeline to copy the ray-traced image
// to the swapchain. To do so we need to render a full-screen triangle.
// We will define a small helper type that defines the data for such a triangle.
//
struct FullScreenTriangle
{
    struct Vertex
    {
        float position[2];
    };

    enum
    {
        kVertexCount = 3
    };

    static const Vertex kVertices[kVertexCount];
};
const FullScreenTriangle::Vertex FullScreenTriangle::kVertices[FullScreenTriangle::kVertexCount] = {
    {{-1, -1}},
    {{-1, 3}},
    {{3, -1}},
};

// The example application will be implemented as a `struct`, so that
// we can scope the resources it allocates without using global variables.
//
struct RayTracing : public WindowedAppBase
{


    Uniforms gUniforms = {};


    // Many Slang API functions return detailed diagnostic information
    // (error messages, warnings, etc.) as a "blob" of data, or return
    // a null blob pointer instead if there were no issues.
    //
    // For convenience, we define a subroutine that will dump the information
    // in a diagnostic blob if one is produced, and skip it otherwise.
    //
    void diagnoseIfNeeded(slang::IBlob* diagnosticsBlob)
    {
        if (diagnosticsBlob != nullptr)
        {
            printf("%s", (const char*)diagnosticsBlob->getBufferPointer());
#ifdef _WIN32
            _Win32OutputDebugString((const char*)diagnosticsBlob->getBufferPointer());
#endif
        }
    }

    // Load and compile shader code from souce.
    gfx::Result loadShaderProgram(
        gfx::IDevice* device,
        bool isRayTracingPipeline,
        gfx::IShaderProgram** outProgram)
    {
        ComPtr<slang::ISession> slangSession;
        slangSession = device->getSlangSession();

        ComPtr<slang::IBlob> diagnosticsBlob;
        Slang::String path = resourceBase.resolveResource("shaders.slang");
        slang::IModule* module =
            slangSession->loadModule(path.getBuffer(), diagnosticsBlob.writeRef());
        diagnoseIfNeeded(diagnosticsBlob);
        if (!module)
            return SLANG_FAIL;

        Slang::List<slang::IComponentType*> componentTypes;
        componentTypes.add(module);
        if (isRayTracingPipeline)
        {
            ComPtr<slang::IEntryPoint> entryPoint;
            SLANG_RETURN_ON_FAIL(
                module->findEntryPointByName("rayGenShader", entryPoint.writeRef()));
            componentTypes.add(entryPoint);
            SLANG_RETURN_ON_FAIL(module->findEntryPointByName("missShader", entryPoint.writeRef()));
            componentTypes.add(entryPoint);
            SLANG_RETURN_ON_FAIL(
                module->findEntryPointByName("closestHitShader", entryPoint.writeRef()));
            componentTypes.add(entryPoint);
            SLANG_RETURN_ON_FAIL(
                module->findEntryPointByName("shadowRayHitShader", entryPoint.writeRef()));
            componentTypes.add(entryPoint);
        }
        else
        {
            ComPtr<slang::IEntryPoint> entryPoint;
            SLANG_RETURN_ON_FAIL(module->findEntryPointByName("vertexMain", entryPoint.writeRef()));
            componentTypes.add(entryPoint);
            SLANG_RETURN_ON_FAIL(
                module->findEntryPointByName("fragmentMain", entryPoint.writeRef()));
            componentTypes.add(entryPoint);
        }

        ComPtr<slang::IComponentType> linkedProgram;
        SlangResult result = slangSession->createCompositeComponentType(
            componentTypes.getBuffer(),
            componentTypes.getCount(),
            linkedProgram.writeRef(),
            diagnosticsBlob.writeRef());
        diagnoseIfNeeded(diagnosticsBlob);
        SLANG_RETURN_ON_FAIL(result);

        if (isTestMode())
        {
            printEntrypointHashes(componentTypes.getCount() - 1, 1, linkedProgram);
        }

        gfx::IShaderProgram::Desc programDesc = {};
        programDesc.slangGlobalScope = linkedProgram;
        SLANG_RETURN_ON_FAIL(device->createProgram(programDesc, outProgram));

        return SLANG_OK;
    }

    ComPtr<gfx::IPipelineState> gPresentPipelineState;
    ComPtr<gfx::IPipelineState> gRenderPipelineState;
    ComPtr<gfx::IBufferResource> gFullScreenVertexBuffer;
    ComPtr<gfx::IBufferResource> gVertexBuffer;
    ComPtr<gfx::IBufferResource> gIndexBuffer;
    ComPtr<gfx::IBufferResource> gPrimitiveBuffer;
    ComPtr<gfx::IBufferResource> gTransformBuffer;
    ComPtr<gfx::IResourceView> gPrimitiveBufferSRV;
    ComPtr<gfx::IBufferResource> gInstanceBuffer;
    ComPtr<gfx::IBufferResource> gBLASBuffer;
    ComPtr<gfx::IAccelerationStructure> gBLAS;
    ComPtr<gfx::IBufferResource> gTLASBuffer;
    ComPtr<gfx::IAccelerationStructure> gTLAS;
    ComPtr<gfx::ITextureResource> gResultTexture;
    ComPtr<gfx::IResourceView> gResultTextureUAV;
    ComPtr<gfx::IShaderTable> gShaderTable;

    uint64_t lastTime = 0;

    // glm::vec3 lightDir = normalize(glm::vec3(10, 10, 10));
    // glm::vec3 lightColor = glm::vec3(1, 1, 1);

    glm::vec3 cameraPosition = glm::vec3(-2.53f, 2.72f, 4.3f);
    float cameraOrientationAngles[2] = {-0.475f, -0.35f}; // Spherical angles (theta, phi).

    float translationScale = 0.5f;
    float rotationScale = 0.01f;

    // In order to control camera movement, we will
    // use good old WASD
    bool wPressed = false;
    bool aPressed = false;
    bool sPressed = false;
    bool dPressed = false;

    bool isMouseDown = false;
    float lastMouseX = 0.0f;
    float lastMouseY = 0.0f;

    void setKeyState(platform::KeyCode key, bool state)
    {
        switch (key)
        {
        default:
            break;
        case platform::KeyCode::W:
            wPressed = state;
            break;
        case platform::KeyCode::A:
            aPressed = state;
            break;
        case platform::KeyCode::S:
            sPressed = state;
            break;
        case platform::KeyCode::D:
            dPressed = state;
            break;
        }
    }
    void onKeyDown(platform::KeyEventArgs args) { setKeyState(args.key, true); }
    void onKeyUp(platform::KeyEventArgs args) { setKeyState(args.key, false); }

    void onMouseDown(platform::MouseEventArgs args)
    {
        isMouseDown = true;
        lastMouseX = (float)args.x;
        lastMouseY = (float)args.y;
    }

    void onMouseMove(platform::MouseEventArgs args)
    {
        if (isMouseDown)
        {
            float deltaX = args.x - lastMouseX;
            float deltaY = args.y - lastMouseY;

            cameraOrientationAngles[0] += -deltaX * rotationScale;
            cameraOrientationAngles[1] += -deltaY * rotationScale;
            lastMouseX = (float)args.x;
            lastMouseY = (float)args.y;
        }
    }
    void onMouseUp(platform::MouseEventArgs args) { isMouseDown = false; }

    Slang::Result initialize()
    {
        SLANG_RETURN_ON_FAIL(initializeBase("Ray Tracing Pipeline", 1024, 768));
        if (!isTestMode())
        {
            gWindow->events.mouseMove = [this](const platform::MouseEventArgs& e)
            { onMouseMove(e); };
            gWindow->events.mouseUp = [this](const platform::MouseEventArgs& e) { onMouseUp(e); };
            gWindow->events.mouseDown = [this](const platform::MouseEventArgs& e)
            { onMouseDown(e); };
            gWindow->events.keyDown = [this](const platform::KeyEventArgs& e) { onKeyDown(e); };
            gWindow->events.keyUp = [this](const platform::KeyEventArgs& e) { onKeyUp(e); };
        }

        IBufferResource::Desc vertexBufferDesc;
        vertexBufferDesc.type = IResource::Type::Buffer;
        vertexBufferDesc.sizeInBytes = kVertexCount * sizeof(Vertex);
        vertexBufferDesc.defaultState = ResourceState::ShaderResource;
        gVertexBuffer = gDevice->createBufferResource(vertexBufferDesc, &kVertexData[0]);
        if (!gVertexBuffer)
            return SLANG_FAIL;

        IBufferResource::Desc indexBufferDesc;
        indexBufferDesc.type = IResource::Type::Buffer;
        indexBufferDesc.sizeInBytes = kIndexCount * sizeof(int32_t);
        indexBufferDesc.defaultState = ResourceState::ShaderResource;
        gIndexBuffer = gDevice->createBufferResource(indexBufferDesc, &kIndexData[0]);
        if (!gIndexBuffer)
            return SLANG_FAIL;

        IBufferResource::Desc primitiveBufferDesc;
        primitiveBufferDesc.type = IResource::Type::Buffer;
        primitiveBufferDesc.sizeInBytes = kPrimitiveCount * sizeof(Primitive);
        primitiveBufferDesc.elementSize = sizeof(Primitive);
        primitiveBufferDesc.defaultState = ResourceState::ShaderResource;
        gPrimitiveBuffer = gDevice->createBufferResource(primitiveBufferDesc, &kPrimitiveData[0]);
        if (!gPrimitiveBuffer)
            return SLANG_FAIL;

        IResourceView::Desc primitiveSRVDesc = {};
        primitiveSRVDesc.format = Format::Unknown;
        primitiveSRVDesc.type = IResourceView::Type::ShaderResource;
        gPrimitiveBufferSRV =
            gDevice->createBufferView(gPrimitiveBuffer, nullptr, primitiveSRVDesc);

        IBufferResource::Desc transformBufferDesc;
        transformBufferDesc.type = IResource::Type::Buffer;
        transformBufferDesc.sizeInBytes = sizeof(float) * 12;
        transformBufferDesc.defaultState = ResourceState::ShaderResource;
        float transformData[12] =
            {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
        gTransformBuffer = gDevice->createBufferResource(transformBufferDesc, &transformData);
        if (!gTransformBuffer)
            return SLANG_FAIL;
        // Build bottom level acceleration structure.
        {
            IAccelerationStructure::BuildInputs accelerationStructureBuildInputs;
            IAccelerationStructure::PrebuildInfo accelerationStructurePrebuildInfo;
            accelerationStructureBuildInputs.descCount = 1;
            accelerationStructureBuildInputs.kind = IAccelerationStructure::Kind::BottomLevel;
            accelerationStructureBuildInputs.flags =
                IAccelerationStructure::BuildFlags::AllowCompaction;
            IAccelerationStructure::GeometryDesc geomDesc;
            geomDesc.flags = IAccelerationStructure::GeometryFlags::Opaque;
            geomDesc.type = IAccelerationStructure::GeometryType::Triangles;
            geomDesc.content.triangles.indexCount = kIndexCount;
            geomDesc.content.triangles.indexData = gIndexBuffer->getDeviceAddress();
            geomDesc.content.triangles.indexFormat = Format::R32_UINT;
            geomDesc.content.triangles.vertexCount = kVertexCount;
            geomDesc.content.triangles.vertexData = gVertexBuffer->getDeviceAddress();
            geomDesc.content.triangles.vertexFormat = Format::R32G32B32_FLOAT;
            geomDesc.content.triangles.vertexStride = sizeof(Vertex);
            geomDesc.content.triangles.transform3x4 = gTransformBuffer->getDeviceAddress();
            accelerationStructureBuildInputs.geometryDescs = &geomDesc;

            // Query buffer size for acceleration structure build.
            SLANG_RETURN_ON_FAIL(gDevice->getAccelerationStructurePrebuildInfo(
                accelerationStructureBuildInputs,
                &accelerationStructurePrebuildInfo));
            // Allocate buffers for acceleration structure.
            IBufferResource::Desc asDraftBufferDesc;
            asDraftBufferDesc.type = IResource::Type::Buffer;
            asDraftBufferDesc.defaultState = ResourceState::AccelerationStructure;
            asDraftBufferDesc.sizeInBytes =
                (size_t)accelerationStructurePrebuildInfo.resultDataMaxSize;
            ComPtr<IBufferResource> draftBuffer = gDevice->createBufferResource(asDraftBufferDesc);
            if (!draftBuffer)
                return SLANG_FAIL;
            IBufferResource::Desc scratchBufferDesc;
            scratchBufferDesc.type = IResource::Type::Buffer;
            scratchBufferDesc.defaultState = ResourceState::UnorderedAccess;
            scratchBufferDesc.sizeInBytes =
                (size_t)accelerationStructurePrebuildInfo.scratchDataSize;
            ComPtr<IBufferResource> scratchBuffer =
                gDevice->createBufferResource(scratchBufferDesc);
            if (!scratchBuffer)
                return SLANG_FAIL;

            // Build acceleration structure.
            ComPtr<IQueryPool> compactedSizeQuery;
            IQueryPool::Desc queryPoolDesc;
            queryPoolDesc.count = 1;
            queryPoolDesc.type = QueryType::AccelerationStructureCompactedSize;
            SLANG_RETURN_ON_FAIL(
                gDevice->createQueryPool(queryPoolDesc, compactedSizeQuery.writeRef()));

            ComPtr<IAccelerationStructure> draftAS;
            IAccelerationStructure::CreateDesc draftCreateDesc;
            draftCreateDesc.buffer = draftBuffer;
            draftCreateDesc.kind = IAccelerationStructure::Kind::BottomLevel;
            draftCreateDesc.offset = 0;
            draftCreateDesc.size = accelerationStructurePrebuildInfo.resultDataMaxSize;
            SLANG_RETURN_ON_FAIL(
                gDevice->createAccelerationStructure(draftCreateDesc, draftAS.writeRef()));

            compactedSizeQuery->reset();

            auto commandBuffer = gTransientHeaps[0]->createCommandBuffer();
            auto encoder = commandBuffer->encodeRayTracingCommands();
            IAccelerationStructure::BuildDesc buildDesc = {};
            buildDesc.dest = draftAS;
            buildDesc.inputs = accelerationStructureBuildInputs;
            buildDesc.scratchData = scratchBuffer->getDeviceAddress();
            AccelerationStructureQueryDesc compactedSizeQueryDesc = {};
            compactedSizeQueryDesc.queryPool = compactedSizeQuery;
            compactedSizeQueryDesc.queryType = QueryType::AccelerationStructureCompactedSize;
            encoder->buildAccelerationStructure(buildDesc, 1, &compactedSizeQueryDesc);
            encoder->endEncoding();
            commandBuffer->close();
            gQueue->executeCommandBuffer(commandBuffer);
            gQueue->waitOnHost();

            uint64_t compactedSize = 0;
            compactedSizeQuery->getResult(0, 1, &compactedSize);
            IBufferResource::Desc asBufferDesc;
            asBufferDesc.type = IResource::Type::Buffer;
            asBufferDesc.defaultState = ResourceState::AccelerationStructure;
            asBufferDesc.sizeInBytes = (size_t)compactedSize;
            gBLASBuffer = gDevice->createBufferResource(asBufferDesc);
            IAccelerationStructure::CreateDesc createDesc;
            createDesc.buffer = gBLASBuffer;
            createDesc.kind = IAccelerationStructure::Kind::BottomLevel;
            createDesc.offset = 0;
            createDesc.size = (size_t)compactedSize;
            gDevice->createAccelerationStructure(createDesc, gBLAS.writeRef());

            commandBuffer = gTransientHeaps[0]->createCommandBuffer();
            encoder = commandBuffer->encodeRayTracingCommands();
            encoder->copyAccelerationStructure(
                gBLAS,
                draftAS,
                AccelerationStructureCopyMode::Compact);
            encoder->endEncoding();
            commandBuffer->close();
            gQueue->executeCommandBuffer(commandBuffer);
            gQueue->waitOnHost();
        }

        // Build top level acceleration structure.
        {
            List<IAccelerationStructure::InstanceDesc> instanceDescs;
            instanceDescs.setCount(1);
            instanceDescs[0].accelerationStructure = gBLAS->getDeviceAddress();
            instanceDescs[0].flags =
                IAccelerationStructure::GeometryInstanceFlags::TriangleFacingCullDisable;
            instanceDescs[0].instanceContributionToHitGroupIndex = 0;
            instanceDescs[0].instanceID = 0;
            instanceDescs[0].instanceMask = 0xFF;
            float transformMatrix[] =
                {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
            memcpy(&instanceDescs[0].transform[0][0], transformMatrix, sizeof(float) * 12);

            IBufferResource::Desc instanceBufferDesc;
            instanceBufferDesc.type = IResource::Type::Buffer;
            instanceBufferDesc.sizeInBytes =
                instanceDescs.getCount() * sizeof(IAccelerationStructure::InstanceDesc);
            instanceBufferDesc.defaultState = ResourceState::ShaderResource;
            gInstanceBuffer =
                gDevice->createBufferResource(instanceBufferDesc, instanceDescs.getBuffer());
            if (!gInstanceBuffer)
                return SLANG_FAIL;

            IAccelerationStructure::BuildInputs accelerationStructureBuildInputs = {};