From f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 29 Oct 2024 14:49:26 +0800 Subject: format * format * Minor test fixes * enable checking cpp format in ci --- examples/shader-object/main.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'examples/shader-object/main.cpp') diff --git a/examples/shader-object/main.cpp b/examples/shader-object/main.cpp index 603278bcf..74d81604b 100644 --- a/examples/shader-object/main.cpp +++ b/examples/shader-object/main.cpp @@ -8,14 +8,14 @@ // simplifies shader specialization and parameter binding when using `interface` typed // shader parameters. // -#include "slang.h" #include "slang-com-ptr.h" +#include "slang.h" using Slang::ComPtr; -#include "slang-gfx.h" +#include "examples/example-base/example-base.h" #include "gfx-util/shader-cursor.h" +#include "slang-gfx.h" #include "source/core/slang-basic.h" -#include "examples/example-base/example-base.h" using namespace gfx; @@ -37,7 +37,7 @@ Result loadShaderProgram( // creates a Slang compilation session for us, so we just grab and use it here. ComPtr slangSession; SLANG_RETURN_ON_FAIL(device->getSlangSession(slangSession.writeRef())); - + // Once the session has been obtained, we can start loading code into it. // // The simplest way to load code is by calling `loadModule` with the name of a Slang @@ -61,7 +61,7 @@ Result loadShaderProgram( Slang::String path = resourceBase.resolveResource("shader-object.slang"); slang::IModule* module = slangSession->loadModule(path.getBuffer(), diagnosticsBlob.writeRef()); diagnoseIfNeeded(diagnosticsBlob); - if(!module) + if (!module) return SLANG_FAIL; // Loading the `shader-object` module will compile and check all the shader code in it, @@ -74,13 +74,13 @@ Result loadShaderProgram( // is no umambiguous way for the compiler to know which functions represent entry // points when it parses your code via `loadModule()`. // - char const* computeEntryPointName = "computeMain"; + char const* computeEntryPointName = "computeMain"; ComPtr computeEntryPoint; SLANG_RETURN_ON_FAIL( module->findEntryPointByName(computeEntryPointName, computeEntryPoint.writeRef())); - + // At this point we have a few different Slang API objects that represent - // pieces of our code: `module`, `vertexEntryPoint`, and `fragmentEntryPoint`. + // pieces of our code: `module`, `vertexEntryPoint`, and `fragmentEntryPoint`. // // A single Slang module could contain many different entry points (e.g., // four vertex entry points, three fragment entry points, and two compute @@ -177,10 +177,8 @@ int main(int argc, char* argv[]) bufferDesc.memoryType = MemoryType::DeviceLocal; ComPtr numbersBuffer; - SLANG_RETURN_ON_FAIL(device->createBufferResource( - bufferDesc, - (void*)initialData, - numbersBuffer.writeRef())); + SLANG_RETURN_ON_FAIL( + device->createBufferResource(bufferDesc, (void*)initialData, numbersBuffer.writeRef())); // Create a resource view for the buffer. ComPtr bufferView; @@ -217,7 +215,9 @@ int main(int argc, char* argv[]) // Now we can use this type to create a shader object that can be bound to the root object. ComPtr transformer; SLANG_RETURN_ON_FAIL(device->createShaderObject( - addTransformerType, ShaderObjectContainerType::None, transformer.writeRef())); + addTransformerType, + ShaderObjectContainerType::None, + transformer.writeRef())); // Set the `c` field of the `AddTransformer`. float c = 1.0f; gfx::ShaderCursor(transformer).getPath("c").setData(&c, sizeof(float)); @@ -244,7 +244,10 @@ int main(int argc, char* argv[]) // Read back the results. ComPtr resultBlob; SLANG_RETURN_ON_FAIL(device->readBufferResource( - numbersBuffer, 0, numberCount * sizeof(float), resultBlob.writeRef())); + numbersBuffer, + 0, + numberCount * sizeof(float), + resultBlob.writeRef())); auto result = reinterpret_cast(resultBlob->getBufferPointer()); for (int i = 0; i < numberCount; i++) printf("%f\n", result[i]); -- cgit v1.2.3