diff --git a/Common_3/OS/iOS/iOSBase.mm b/Common_3/OS/iOS/iOSBase.mm index 0777cb314d..69d221d0a9 100644 --- a/Common_3/OS/iOS/iOSBase.mm +++ b/Common_3/OS/iOS/iOSBase.mm @@ -82,7 +82,7 @@ unsigned getSystemTime() time_t s; // Seconds struct timespec spec; - clock_gettime(CLOCK_REALTIME, &spec); + clock_gettime(_CLOCK_MONOTONIC, &spec); s = spec.tv_sec; ms = round(spec.tv_nsec / 1.0e6); // Convert nanoseconds to milliseconds @@ -95,7 +95,7 @@ unsigned getSystemTime() int64_t getUSec() { timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(_CLOCK_MONOTONIC, &ts); long us = (ts.tv_nsec / 1000); us += ts.tv_sec * 1e6; return us; diff --git a/Common_3/OS/macOS/macOSBase.mm b/Common_3/OS/macOS/macOSBase.mm index b3fcff893f..0e44e8f389 100644 --- a/Common_3/OS/macOS/macOSBase.mm +++ b/Common_3/OS/macOS/macOSBase.mm @@ -249,7 +249,7 @@ unsigned getSystemTime() time_t s; // Seconds struct timespec spec; - clock_gettime(CLOCK_REALTIME, &spec); + clock_gettime(_CLOCK_MONOTONIC, &spec); s = spec.tv_sec; ms = round(spec.tv_nsec / 1.0e6); // Convert nanoseconds to milliseconds @@ -262,7 +262,7 @@ unsigned getSystemTime() int64_t getUSec() { timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(_CLOCK_MONOTONIC, &ts); long us = (ts.tv_nsec / 1000); us += ts.tv_sec * 1e6; return us; diff --git a/Common_3/Renderer/Direct3D11/Direct3D11CapBuilder.h b/Common_3/Renderer/Direct3D11/Direct3D11CapBuilder.h index fd19231b2c..1c5e37b39d 100644 --- a/Common_3/Renderer/Direct3D11/Direct3D11CapBuilder.h +++ b/Common_3/Renderer/Direct3D11/Direct3D11CapBuilder.h @@ -6,7 +6,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { memset(pRenderer->capBits.canShaderReadFrom, 0, sizeof(pRenderer->capBits.canShaderReadFrom)); memset(pRenderer->capBits.canShaderWriteTo, 0, sizeof(pRenderer->capBits.canShaderWriteTo)); - memset(pRenderer->capBits.canColorWriteTo, 0, sizeof(pRenderer->capBits.canColorWriteTo)); + memset(pRenderer->capBits.canRenderTargetWriteTo, 0, sizeof(pRenderer->capBits.canRenderTargetWriteTo)); for (uint32_t i = 0; i < TinyImageFormat_Count;++i) { DXGI_FORMAT fmt = (DXGI_FORMAT) TinyImageFormat_ToDXGI_FORMAT((TinyImageFormat)i); @@ -17,7 +17,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { pRenderer->pDxDevice->CheckFormatSupport(fmt, &formatSupport); pRenderer->capBits.canShaderReadFrom[i] = (formatSupport & D3D11_FORMAT_SUPPORT_SHADER_SAMPLE) != 0; pRenderer->capBits.canShaderWriteTo[i] = (formatSupport & D3D11_FORMAT_SUPPORT_TYPED_UNORDERED_ACCESS_VIEW) != 0; - pRenderer->capBits.canColorWriteTo[i] = (formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0; + pRenderer->capBits.canRenderTargetWriteTo[i] = (formatSupport & D3D11_FORMAT_SUPPORT_RENDER_TARGET) != 0; } } diff --git a/Common_3/Renderer/Direct3D12/Direct3D12CapBuilder.h b/Common_3/Renderer/Direct3D12/Direct3D12CapBuilder.h index 7108a1a157..23e675ed0b 100644 --- a/Common_3/Renderer/Direct3D12/Direct3D12CapBuilder.h +++ b/Common_3/Renderer/Direct3D12/Direct3D12CapBuilder.h @@ -6,7 +6,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { memset(pRenderer->capBits.canShaderReadFrom, 0, sizeof(pRenderer->capBits.canShaderReadFrom)); memset(pRenderer->capBits.canShaderWriteTo, 0, sizeof(pRenderer->capBits.canShaderWriteTo)); - memset(pRenderer->capBits.canColorWriteTo, 0, sizeof(pRenderer->capBits.canColorWriteTo)); + memset(pRenderer->capBits.canRenderTargetWriteTo, 0, sizeof(pRenderer->capBits.canRenderTargetWriteTo)); for (uint32_t i = 0; i < TinyImageFormat_Count;++i) { DXGI_FORMAT fmt = (DXGI_FORMAT) TinyImageFormat_ToDXGI_FORMAT((TinyImageFormat)i); @@ -17,7 +17,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { pRenderer->pDxDevice->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &formatSupport, sizeof(formatSupport)); pRenderer->capBits.canShaderReadFrom[i] = (formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE) != 0; pRenderer->capBits.canShaderWriteTo[i] = (formatSupport.Support2 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE) != 0; - pRenderer->capBits.canColorWriteTo[i] = (formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_RENDER_TARGET) != 0; + pRenderer->capBits.canRenderTargetWriteTo[i] = (formatSupport.Support1 & D3D12_FORMAT_SUPPORT1_RENDER_TARGET) != 0; } } diff --git a/Common_3/Renderer/IRenderer.h b/Common_3/Renderer/IRenderer.h index c821eac6e5..bdfe761969 100644 --- a/Common_3/Renderer/IRenderer.h +++ b/Common_3/Renderer/IRenderer.h @@ -906,10 +906,6 @@ typedef struct RenderTarget #if defined(VULKAN) VkImageView* pVkDescriptors; #endif -#if defined(TARGET_IOS) - // A separate texture is needed for stencil rendering on iOS. - Texture* pStencil; -#endif #if defined(DIRECT3D11) union { @@ -1765,7 +1761,7 @@ typedef struct GPUVendorPreset typedef struct GPUCapBits { bool canShaderReadFrom[TinyImageFormat_Count]; bool canShaderWriteTo[TinyImageFormat_Count]; - bool canColorWriteTo[TinyImageFormat_Count]; + bool canRenderTargetWriteTo[TinyImageFormat_Count]; } GPUCapBits; typedef enum DefaultResourceAlignment diff --git a/Common_3/Renderer/Metal/MetalCapBuilder.h b/Common_3/Renderer/Metal/MetalCapBuilder.h index 7bcc2fb51c..13f7bf1027 100644 --- a/Common_3/Renderer/Metal/MetalCapBuilder.h +++ b/Common_3/Renderer/Metal/MetalCapBuilder.h @@ -8,7 +8,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { memset(pRenderer->capBits.canShaderReadFrom, 0, sizeof(pRenderer->capBits.canShaderReadFrom)); memset(pRenderer->capBits.canShaderWriteTo, 0, sizeof(pRenderer->capBits.canShaderWriteTo)); - memset(pRenderer->capBits.canColorWriteTo, 0, sizeof(pRenderer->capBits.canColorWriteTo)); + memset(pRenderer->capBits.canRenderTargetWriteTo, 0, sizeof(pRenderer->capBits.canRenderTargetWriteTo)); // all pixel formats that metal support it claims can be sampled from if they exist on the platform // this is however a lie when compressed texture formats @@ -26,7 +26,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { } } #define CAN_SHADER_WRITE(x) pRenderer->capBits.canShaderWriteTo[TinyImageFormat_##x] = true; -#define CAN_COLOR_WRITE(x) pRenderer->capBits.canColorWriteTo[TinyImageFormat_##x] = true; +#define CAN_RENDER_TARGET_WRITE(x) pRenderer->capBits.canRenderTargetWriteTo[TinyImageFormat_##x] = true; // this call is supported on mac and ios // technially I think you can write but not read some texture, this is telling @@ -66,42 +66,57 @@ inline void utils_caps_builder(Renderer* pRenderer) { familyTier = [pRenderer->pDevice supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily1_v4] ? 1 : familyTier; if( familyTier >= 1 ) { - CAN_COLOR_WRITE(R8_UNORM); // this has a subscript 8 which makes no sense - CAN_COLOR_WRITE(R8_SNORM); - CAN_COLOR_WRITE(R8_UINT); - CAN_COLOR_WRITE(R8_SINT); - - CAN_COLOR_WRITE(R16_UNORM); - CAN_COLOR_WRITE(R16_SNORM); - CAN_COLOR_WRITE(R16_SFLOAT); - CAN_COLOR_WRITE(R16_UINT); - CAN_COLOR_WRITE(R16_SINT); - - CAN_COLOR_WRITE(R8G8_UNORM); - CAN_COLOR_WRITE(R8G8_SNORM); - CAN_COLOR_WRITE(R8G8_UINT); - CAN_COLOR_WRITE(R8G8_SINT); - - CAN_COLOR_WRITE(R8G8B8A8_UNORM); - CAN_COLOR_WRITE(R8G8B8A8_SNORM); - CAN_COLOR_WRITE(R8G8B8A8_SRGB); - CAN_COLOR_WRITE(B8G8R8A8_UNORM); - CAN_COLOR_WRITE(B8G8R8A8_SRGB); - CAN_COLOR_WRITE(R16G16_UNORM); - CAN_COLOR_WRITE(R16G16_SNORM); - CAN_COLOR_WRITE(R16G16_SFLOAT); - CAN_COLOR_WRITE(R32_SFLOAT); - CAN_COLOR_WRITE(A2R10G10B10_UNORM); - CAN_COLOR_WRITE(A2B10G10R10_UNORM); - CAN_COLOR_WRITE(B10G11R11_UFLOAT); - - CAN_COLOR_WRITE(R16G16B16A16_UNORM); - CAN_COLOR_WRITE(R16G16B16A16_SNORM); - CAN_COLOR_WRITE(R16G16B16A16_SFLOAT); - CAN_COLOR_WRITE(R32G32_SFLOAT); - - CAN_COLOR_WRITE(R32G32B32A32_SFLOAT); + CAN_RENDER_TARGET_WRITE(R8_UNORM); // this has a subscript 8 which makes no sense + CAN_RENDER_TARGET_WRITE(R8_SNORM); + CAN_RENDER_TARGET_WRITE(R8_UINT); + CAN_RENDER_TARGET_WRITE(R8_SINT); + + CAN_RENDER_TARGET_WRITE(R16_UNORM); + CAN_RENDER_TARGET_WRITE(R16_SNORM); + CAN_RENDER_TARGET_WRITE(R16_SFLOAT); + CAN_RENDER_TARGET_WRITE(R16_UINT); + CAN_RENDER_TARGET_WRITE(R16_SINT); + + CAN_RENDER_TARGET_WRITE(R8G8_UNORM); + CAN_RENDER_TARGET_WRITE(R8G8_SNORM); + CAN_RENDER_TARGET_WRITE(R8G8_UINT); + CAN_RENDER_TARGET_WRITE(R8G8_SINT); + + CAN_RENDER_TARGET_WRITE(R8G8B8A8_UNORM); + CAN_RENDER_TARGET_WRITE(R8G8B8A8_SNORM); + CAN_RENDER_TARGET_WRITE(R8G8B8A8_SRGB); + CAN_RENDER_TARGET_WRITE(B8G8R8A8_UNORM); + CAN_RENDER_TARGET_WRITE(B8G8R8A8_SRGB); + CAN_RENDER_TARGET_WRITE(R16G16_UNORM); + CAN_RENDER_TARGET_WRITE(R16G16_SNORM); + CAN_RENDER_TARGET_WRITE(R16G16_SFLOAT); + CAN_RENDER_TARGET_WRITE(R32_SFLOAT); + CAN_RENDER_TARGET_WRITE(A2R10G10B10_UNORM); + CAN_RENDER_TARGET_WRITE(A2B10G10R10_UNORM); + CAN_RENDER_TARGET_WRITE(B10G11R11_UFLOAT); + + CAN_RENDER_TARGET_WRITE(R16G16B16A16_UNORM); + CAN_RENDER_TARGET_WRITE(R16G16B16A16_SNORM); + CAN_RENDER_TARGET_WRITE(R16G16B16A16_SFLOAT); + CAN_RENDER_TARGET_WRITE(R32G32_SFLOAT); + + CAN_RENDER_TARGET_WRITE(R32G32B32A32_SFLOAT); + + CAN_RENDER_TARGET_WRITE(D16_UNORM); + CAN_RENDER_TARGET_WRITE(D32_SFLOAT); + CAN_RENDER_TARGET_WRITE(S8_UINT); + CAN_RENDER_TARGET_WRITE(D32_SFLOAT_S8_UINT); }; + + bool depth24Stencil8Supported = [pRenderer->pDevice isDepth24Stencil8PixelFormatSupported]; + + pRenderer->capBits.canShaderReadFrom[TinyImageFormat_D24_UNORM_S8_UINT] = depth24Stencil8Supported; + pRenderer->capBits.canShaderReadFrom[TinyImageFormat_X8_D24_UNORM] = depth24Stencil8Supported; + pRenderer->capBits.canShaderWriteTo[TinyImageFormat_D24_UNORM_S8_UINT] = depth24Stencil8Supported; + pRenderer->capBits.canShaderWriteTo[TinyImageFormat_X8_D24_UNORM] = depth24Stencil8Supported; + pRenderer->capBits.canRenderTargetWriteTo[TinyImageFormat_D24_UNORM_S8_UINT] = depth24Stencil8Supported; + pRenderer->capBits.canRenderTargetWriteTo[TinyImageFormat_X8_D24_UNORM] = depth24Stencil8Supported; + #else // iOS uint32_t familyTier = 0; familyTier = [pRenderer->pDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v1] ? 1 : familyTier; @@ -159,53 +174,63 @@ inline void utils_caps_builder(Renderer* pRenderer) { } if(familyTier >= 1) { - CAN_COLOR_WRITE(R8_UNORM); // this has a subscript 8 which makes no sense - CAN_COLOR_WRITE(R8_SNORM); - CAN_COLOR_WRITE(R8_UINT); - CAN_COLOR_WRITE(R8_SINT); - CAN_COLOR_WRITE(R8_SRGB); - - CAN_COLOR_WRITE(R16_UNORM); - CAN_COLOR_WRITE(R16_SNORM); - CAN_COLOR_WRITE(R16_SFLOAT); - CAN_COLOR_WRITE(R16_UINT); - CAN_COLOR_WRITE(R16_SINT); - - CAN_COLOR_WRITE(R8G8_UNORM); - CAN_COLOR_WRITE(R8G8_SNORM); - CAN_COLOR_WRITE(R8G8_SRGB); - CAN_COLOR_WRITE(R8G8_UINT); - CAN_COLOR_WRITE(R8G8_SINT); - - CAN_COLOR_WRITE(B5G6R5_UNORM); - CAN_COLOR_WRITE(A1R5G5B5_UNORM); - CAN_COLOR_WRITE(A4B4G4R4_UNORM); - CAN_COLOR_WRITE(R5G6B5_UNORM); - CAN_COLOR_WRITE(B5G5R5A1_UNORM); - - CAN_COLOR_WRITE(R8G8B8A8_UNORM); - CAN_COLOR_WRITE(R8G8B8A8_SNORM); - CAN_COLOR_WRITE(R8G8B8A8_SRGB); - CAN_COLOR_WRITE(B8G8R8A8_UNORM); - CAN_COLOR_WRITE(B8G8R8A8_SRGB); - CAN_COLOR_WRITE(R16G16_UNORM); - CAN_COLOR_WRITE(R16G16_SNORM); - CAN_COLOR_WRITE(R16G16_SFLOAT); - CAN_COLOR_WRITE(R32_SFLOAT); - CAN_COLOR_WRITE(A2R10G10B10_UNORM); - CAN_COLOR_WRITE(A2B10G10R10_UNORM); - CAN_COLOR_WRITE(B10G11R11_UFLOAT); - - CAN_COLOR_WRITE(R16G16B16A16_UNORM); - CAN_COLOR_WRITE(R16G16B16A16_SNORM); - CAN_COLOR_WRITE(R16G16B16A16_SFLOAT); - CAN_COLOR_WRITE(R32G32_SFLOAT); - - CAN_COLOR_WRITE(R32G32B32A32_SFLOAT); + CAN_RENDER_TARGET_WRITE(R8_UNORM); // this has a subscript 8 which makes no sense + CAN_RENDER_TARGET_WRITE(R8_SNORM); + CAN_RENDER_TARGET_WRITE(R8_UINT); + CAN_RENDER_TARGET_WRITE(R8_SINT); + CAN_RENDER_TARGET_WRITE(R8_SRGB); + + CAN_RENDER_TARGET_WRITE(R16_UNORM); + CAN_RENDER_TARGET_WRITE(R16_SNORM); + CAN_RENDER_TARGET_WRITE(R16_SFLOAT); + CAN_RENDER_TARGET_WRITE(R16_UINT); + CAN_RENDER_TARGET_WRITE(R16_SINT); + + CAN_RENDER_TARGET_WRITE(R8G8_UNORM); + CAN_RENDER_TARGET_WRITE(R8G8_SNORM); + CAN_RENDER_TARGET_WRITE(R8G8_SRGB); + CAN_RENDER_TARGET_WRITE(R8G8_UINT); + CAN_RENDER_TARGET_WRITE(R8G8_SINT); + + CAN_RENDER_TARGET_WRITE(B5G6R5_UNORM); + CAN_RENDER_TARGET_WRITE(A1R5G5B5_UNORM); + CAN_RENDER_TARGET_WRITE(A4B4G4R4_UNORM); + CAN_RENDER_TARGET_WRITE(R5G6B5_UNORM); + CAN_RENDER_TARGET_WRITE(B5G5R5A1_UNORM); + + CAN_RENDER_TARGET_WRITE(R8G8B8A8_UNORM); + CAN_RENDER_TARGET_WRITE(R8G8B8A8_SNORM); + CAN_RENDER_TARGET_WRITE(R8G8B8A8_SRGB); + CAN_RENDER_TARGET_WRITE(B8G8R8A8_UNORM); + CAN_RENDER_TARGET_WRITE(B8G8R8A8_SRGB); + CAN_RENDER_TARGET_WRITE(R16G16_UNORM); + CAN_RENDER_TARGET_WRITE(R16G16_SNORM); + CAN_RENDER_TARGET_WRITE(R16G16_SFLOAT); + CAN_RENDER_TARGET_WRITE(R32_SFLOAT); + CAN_RENDER_TARGET_WRITE(A2R10G10B10_UNORM); + CAN_RENDER_TARGET_WRITE(A2B10G10R10_UNORM); + CAN_RENDER_TARGET_WRITE(B10G11R11_UFLOAT); + + CAN_RENDER_TARGET_WRITE(R16G16B16A16_UNORM); + CAN_RENDER_TARGET_WRITE(R16G16B16A16_SNORM); + CAN_RENDER_TARGET_WRITE(R16G16B16A16_SFLOAT); + CAN_RENDER_TARGET_WRITE(R32G32_SFLOAT); + + CAN_RENDER_TARGET_WRITE(R32G32B32A32_SFLOAT); + + CAN_RENDER_TARGET_WRITE(D32_SFLOAT); + CAN_RENDER_TARGET_WRITE(S8_UINT); + CAN_RENDER_TARGET_WRITE(D32_SFLOAT_S8_UINT); + CAN_RENDER_TARGET_WRITE(D32_SFLOAT_S8_UINT); + } + + if (@available(iOS 13, *)) { + pRenderer->capBits.canShaderWriteTo[TinyImageFormat_D16_UNORM] = true; + pRenderer->capBits.canRenderTargetWriteTo[TinyImageFormat_D16_UNORM] = true; } #endif #undef CAN_SHADER_WRITE -#undef CAN_COLOR_WRITE +#undef CAN_RENDER_TARGET_WRITE } diff --git a/Common_3/Renderer/Metal/MetalMemoryAllocator.h b/Common_3/Renderer/Metal/MetalMemoryAllocator.h index 58b99fddef..2f57a48d87 100644 --- a/Common_3/Renderer/Metal/MetalMemoryAllocator.h +++ b/Common_3/Renderer/Metal/MetalMemoryAllocator.h @@ -3521,7 +3521,7 @@ long createBuffer( { pBuffer->mtlBuffer = [pBuffer->pMtlAllocation->GetMemory() newBufferWithLength:pCreateInfo->mSize options:mtlResourceOptions]; assert(pBuffer->mtlBuffer); - pBuffer->mtlBuffer.label = [NSString stringWithFormat:@"Placed Buffer %llx", (uint64_t)pBuffer->mtlBuffer]; + pBuffer->mtlBuffer.label = [NSString stringWithFormat:@"Placed Buffer %p", pBuffer->mtlBuffer]; if (pMemoryRequirements->flags & RESOURCE_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT) { @@ -3541,7 +3541,7 @@ long createBuffer( { pBuffer->mtlBuffer = [allocator->m_Device newBufferWithLength:pCreateInfo->mSize options:mtlResourceOptions]; assert(pBuffer->mtlBuffer); - pBuffer->mtlBuffer.label = [NSString stringWithFormat:@"Owned Buffer %llx", (uint64_t)pBuffer->mtlBuffer]; + pBuffer->mtlBuffer.label = [NSString stringWithFormat:@"Owned Buffer %p", pBuffer->mtlBuffer]; if (pMemoryRequirements->flags & RESOURCE_MEMORY_REQUIREMENT_PERSISTENT_MAP_BIT && pMemoryRequirements->usage != RESOURCE_MEMORY_USAGE_GPU_ONLY) @@ -3552,7 +3552,7 @@ long createBuffer( if (pCreateInfo->pDebugName) { - pBuffer->mtlBuffer.label = [[[NSString alloc] initWithBytesNoCopy:(void*)pCreateInfo->pDebugName length: wcslen(pCreateInfo->pDebugName)*4 encoding:NSUTF32LittleEndianStringEncoding freeWhenDone:NO] stringByAppendingFormat:@" %llx", (uint64_t)pBuffer->mtlBuffer]; + pBuffer->mtlBuffer.label = [[[NSString alloc] initWithBytesNoCopy:(void*)pCreateInfo->pDebugName length: wcslen(pCreateInfo->pDebugName)*4 encoding:NSUTF32LittleEndianStringEncoding freeWhenDone:NO] stringByAppendingFormat:@" %p", pBuffer->mtlBuffer]; } // Bind buffer with memory. @@ -3603,7 +3603,23 @@ long createTexture( AllocatorSuballocationType suballocType; if (!resourceAllocFindSuballocType(pCreateInfo->pDesc, &suballocType)) return false; - + +#ifdef TARGET_IOS + // For memoryless textures, avoid a heap allocation. + if ([pCreateInfo->pDesc storageMode] == MTLStorageModeMemoryless) + { + pTexture->mtlTexture = [allocator->m_Device newTextureWithDescriptor:pCreateInfo->pDesc]; + assert(pTexture->mtlTexture); + pTexture->mtlTexture.label = [NSString stringWithFormat:@"Memoryless Texture %p", pTexture->mtlTexture]; + + if (pCreateInfo->pDebugName) + { + pTexture->mtlTexture.label = [[NSString alloc] initWithBytesNoCopy:(void*)pCreateInfo->pDebugName length: wcslen(pCreateInfo->pDebugName)*4 encoding:NSUTF32LittleEndianStringEncoding freeWhenDone:NO]; + } + return true; + } +#endif + // Allocate memory using allocator. AllocationInfo info; info.mSizeAlign = [allocator->m_Device heapTextureSizeAndAlignWithDescriptor:pCreateInfo->pDesc]; @@ -3617,18 +3633,18 @@ long createTexture( { pTexture->mtlTexture = [pTexture->pMtlAllocation->GetMemory() newTextureWithDescriptor:pCreateInfo->pDesc]; assert(pTexture->mtlTexture); - pTexture->mtlTexture.label = [NSString stringWithFormat:@"Placed Texture %llx", (uint64_t)pTexture->mtlTexture]; + pTexture->mtlTexture.label = [NSString stringWithFormat:@"Placed Texture %p", pTexture->mtlTexture]; } else { pTexture->mtlTexture = [allocator->m_Device newTextureWithDescriptor:pCreateInfo->pDesc]; assert(pTexture->mtlTexture); - pTexture->mtlTexture.label = [NSString stringWithFormat:@"Owned Texture %llx", (uint64_t)pTexture->mtlTexture]; + pTexture->mtlTexture.label = [NSString stringWithFormat:@"Owned Texture %p", pTexture->mtlTexture]; } if (pCreateInfo->pDebugName) { - pTexture->mtlTexture.label = [[[NSString alloc] initWithBytesNoCopy:(void*)pCreateInfo->pDebugName length: wcslen(pCreateInfo->pDebugName)*4 encoding:NSUTF32LittleEndianStringEncoding freeWhenDone:NO] stringByAppendingFormat:@" %llx", (uint64_t)pTexture->mtlTexture]; + pTexture->mtlTexture.label = [[[NSString alloc] initWithBytesNoCopy:(void*)pCreateInfo->pDebugName length: wcslen(pCreateInfo->pDebugName)*4 encoding:NSUTF32LittleEndianStringEncoding freeWhenDone:NO] stringByAppendingFormat:@" %p", pTexture->mtlTexture]; //[pTexture->mtlTexture.label ]; } diff --git a/Common_3/Renderer/Metal/MetalRaytracing.mm b/Common_3/Renderer/Metal/MetalRaytracing.mm index 1cc7fcf1f7..024a863b38 100644 --- a/Common_3/Renderer/Metal/MetalRaytracing.mm +++ b/Common_3/Renderer/Metal/MetalRaytracing.mm @@ -129,7 +129,7 @@ }; //implemented in MetalRenderer.mm - extern void util_end_current_encoders(Cmd* pCmd); + extern void util_end_current_encoders(Cmd* pCmd, bool forceBarrier); bool isRaytracingSupported(Renderer* pRenderer) { @@ -565,7 +565,7 @@ void cmdCopyTexture(Cmd* pCmd, Texture* pDst, Texture* pSrc) ASSERT(pDst->mDesc.mHeight == pSrc->mDesc.mHeight); ASSERT(pDst->mDesc.mMipLevels == pSrc->mDesc.mMipLevels); ASSERT(pDst->mDesc.mArraySize == pSrc->mDesc.mArraySize); - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); pCmd->mtlBlitEncoder = [pCmd->mtlCommandBuffer blitCommandEncoder]; @@ -990,7 +990,7 @@ void invokeShader(Cmd* pCmd, Raytracing* pRaytracing, if (pShadersInfo->pHitReferences[shaderId].active) { - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); uint32_t hitRef = pShadersInfo->pHitReferences[shaderId].hitShader; uint32_t missRef = pShadersInfo->pHitReferences[shaderId].missShader; NSUInteger width = (NSUInteger)pDesc->mWidth; @@ -1073,7 +1073,7 @@ void cmdDispatchRays(Cmd* pCmd, Raytracing* pRaytracing, const RaytracingDispatc [computeEncoder popDebugGroup]; // End the encoder - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); if (!pDesc->pShaderTable->mInvokeShaders) return; diff --git a/Common_3/Renderer/Metal/MetalRenderer.mm b/Common_3/Renderer/Metal/MetalRenderer.mm index 3ba27579ac..4a0074e1b8 100644 --- a/Common_3/Renderer/Metal/MetalRenderer.mm +++ b/Common_3/Renderer/Metal/MetalRenderer.mm @@ -256,12 +256,12 @@ inline void MurmurHash3_x86_32(const void * key, int len, uint32_t seed, void * // Internal utility functions (may become external one day) uint64_t util_pthread_to_uint64(const pthread_t& value); -bool util_is_compatible_texture_view(const MTLTextureType& textureType, const MTLTextureType& subviewTye); +bool util_is_compatible_texture_view(const MTLTextureType textureType, const MTLTextureType subviewTye); -bool util_is_mtl_depth_pixel_format(const MTLPixelFormat& format); -bool util_is_mtl_compressed_pixel_format(const MTLPixelFormat& format); -MTLVertexFormat util_to_mtl_vertex_format(const TinyImageFormat& format); -MTLLoadAction util_to_mtl_load_action(const LoadActionType& loadActionType); +bool util_is_mtl_depth_pixel_format(const MTLPixelFormat format); +bool util_is_mtl_compressed_pixel_format(const MTLPixelFormat format); +MTLVertexFormat util_to_mtl_vertex_format(const TinyImageFormat format); +MTLLoadAction util_to_mtl_load_action(const LoadActionType loadActionType); void add_texture(Renderer* pRenderer, const TextureDesc* pDesc, Texture** ppTexture, const bool isRT = false, const bool forceNonPrivate = false); @@ -562,7 +562,8 @@ const RendererShaderDefinesDesc get_renderer_shaderdefines(Renderer* pRenderer) /************************************************************************/ void util_bind_argument_buffer(Cmd* pCmd, DescriptorBinderNode& node, const DescriptorInfo* descInfo, const DescriptorData* descData); -void util_end_current_encoders(Cmd* pCmd); +void util_end_current_encoders(Cmd* pCmd, bool forceBarrier); +void util_barrier_update(Cmd* pCmd, const CmdPoolType& encoderType); void util_barrier_required(Cmd* pCmd, const CmdPoolType& encoderType); void reset_bound_resources(DescriptorBinder* pDescriptorBinder, RootSignature* pRootSignature) @@ -633,37 +634,38 @@ void util_set_resources_graphics(Cmd* pCmd, DescriptorSet::DescriptorResources* switch (i) { case RESOURCE_TYPE_RESOURCE_RW: - if (@available(iOS 13.0, *)) + if(@available(iOS 13.0, macOS 15.0, *)) { [pCmd->mtlRenderEncoder useResources: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount - usage: MTLResourceUsageRead | MTLResourceUsageWrite + usage: MTLResourceUsageRead | MTLResourceUsageSample | MTLResourceUsageWrite stages: stages]; + } else { [pCmd->mtlRenderEncoder useResources: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount - usage: MTLResourceUsageRead | MTLResourceUsageWrite]; + usage: MTLResourceUsageRead | MTLResourceUsageSample | MTLResourceUsageWrite]; } break; case RESOURCE_TYPE_RESOURCE_READ_ONLY: - if (@available(iOS 13.0, *)) + if(@available(iOS 13.0, macOS 15.0, *)) { [pCmd->mtlRenderEncoder useResources: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount - usage: MTLResourceUsageRead + usage: MTLResourceUsageRead | MTLResourceUsageSample stages: stages]; } else { [pCmd->mtlRenderEncoder useResources: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount - usage: MTLResourceUsageRead]; + usage: MTLResourceUsageRead | MTLResourceUsageSample]; } break; case RESOURCE_TYPE_HEAP: - if (@available(iOS 13.0, *)) + if(@available(iOS 13.0, macOS 15.0, *)) { [pCmd->mtlRenderEncoder useHeaps: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount @@ -696,12 +698,12 @@ void util_set_resources_compute(Cmd* pCmd, DescriptorSet::DescriptorResources* r case RESOURCE_TYPE_RESOURCE_RW: [pCmd->mtlComputeEncoder useResources: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount - usage: MTLResourceUsageRead | MTLResourceUsageWrite]; + usage: MTLResourceUsageRead | MTLResourceUsageSample | MTLResourceUsageWrite]; break; case RESOURCE_TYPE_RESOURCE_READ_ONLY: [pCmd->mtlComputeEncoder useResources: (__unsafe_unretained id*)(void*)resources->mResources[i] count: resourceCount - usage: MTLResourceUsageRead]; + usage: MTLResourceUsageRead | MTLResourceUsageSample]; break; case RESOURCE_TYPE_HEAP: [pCmd->mtlComputeEncoder useHeaps: (__unsafe_unretained id*)(void*)resources->mResources[i] @@ -2365,20 +2367,7 @@ void addRenderTarget(Renderer* pRenderer, const RenderTargetDesc* pDesc, RenderT rtDesc.mDescriptors |= pDesc->mDescriptors; -#ifndef TARGET_IOS add_texture(pRenderer, &rtDesc, &pRenderTarget->pTexture, true); -#else - if (pDesc->mFormat != TinyImageFormat_D24_UNORM_S8_UINT) - add_texture(pRenderer, &rtDesc, &pRenderTarget->pTexture, true); - // Combined depth stencil is not supported on iOS. - else - { - rtDesc.mFormat = TinyImageFormat_X8_D24_UNORM; - add_texture(pRenderer, &rtDesc, &pRenderTarget->pTexture, true); - rtDesc.mFormat = TinyImageFormat_S8_UINT; - add_texture(pRenderer, &rtDesc, &pRenderTarget->pStencil, true); - } -#endif *ppRenderTarget = pRenderTarget; } @@ -2402,10 +2391,6 @@ void removeTexture(Renderer* pRenderer, Texture* pTexture) void removeRenderTarget(Renderer* pRenderer, RenderTarget* pRenderTarget) { removeTexture(pRenderer, pRenderTarget->pTexture); -#ifdef TARGET_IOS - if (pRenderTarget->pStencil) - removeTexture(pRenderer, pRenderTarget->pStencil); -#endif SAFE_FREE(pRenderTarget); } @@ -2531,6 +2516,7 @@ void addShader(Renderer* pRenderer, const ShaderDesc* pDesc, Shader** ppShaderPr LOGF(LogLevel::eWARNING, "Loaded shader %s with the following warnings:\n %s", shader_name, [[error localizedDescription] UTF8String]); error = 0; // error string is an autorelease object. + //ASSERT(0); } // Error else @@ -2538,6 +2524,7 @@ void addShader(Renderer* pRenderer, const ShaderDesc* pDesc, Shader** ppShaderPr LOGF(LogLevel::eERROR, "Couldn't load shader %s with the following error:\n %s", shader_name, [[error localizedDescription] UTF8String]); error = 0; // error string is an autorelease object. + ASSERT(0); } } @@ -2881,13 +2868,8 @@ void addGraphicsPipelineImpl(Renderer* pRenderer, const GraphicsPipelineDesc* pD if (pDesc->mDepthStencilFormat != TinyImageFormat_UNDEFINED) { renderPipelineDesc.depthAttachmentPixelFormat = (MTLPixelFormat) TinyImageFormat_ToMTLPixelFormat(pDesc->mDepthStencilFormat); -#ifndef TARGET_IOS - if (renderPipelineDesc.depthAttachmentPixelFormat == MTLPixelFormatDepth24Unorm_Stencil8) + if (pDesc->mDepthStencilFormat == TinyImageFormat_D24_UNORM_S8_UINT || pDesc->mDepthStencilFormat == TinyImageFormat_D32_SFLOAT_S8_UINT) renderPipelineDesc.stencilAttachmentPixelFormat = renderPipelineDesc.depthAttachmentPixelFormat; -#else - if (pDesc->mDepthStencilFormat == TinyImageFormat_D24_UNORM_S8_UINT) - renderPipelineDesc.stencilAttachmentPixelFormat = MTLPixelFormatStencil8; -#endif } // assign common tesselation configuration if needed. @@ -3206,7 +3188,7 @@ void endCmd(Cmd* pCmd) @autoreleasepool { - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, true); } } @@ -3244,7 +3226,7 @@ void cmdBindRenderTargets( */ @autoreleasepool { - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, true); } pCmd->mRenderPassActive = false; @@ -3268,14 +3250,12 @@ void cmdBindRenderTargets( pCmd->pRenderPassDesc.colorAttachments[i].slice = pColorArraySlices ? pColorArraySlices[i] : 0; else if (colorAttachment->mDesc.mDescriptors & DESCRIPTOR_TYPE_RENDER_TARGET_DEPTH_SLICES) pCmd->pRenderPassDesc.colorAttachments[i].depthPlane = pColorArraySlices ? pColorArraySlices[i] : 0; -#ifndef TARGET_IOS - pCmd->pRenderPassDesc.colorAttachments[i].loadAction = - (pLoadActions != NULL ? util_to_mtl_load_action(pLoadActions->mLoadActionsColor[i]) : MTLLoadActionLoad); - pCmd->pRenderPassDesc.colorAttachments[i].storeAction = MTLStoreActionStore; -#else - if (colorAttachment->mtlTexture.storageMode == MTLStorageModeMemoryless) + + // For on-tile (memoryless) textures, we never need to load or store. + if (colorAttachment->mDesc.mFlags & TEXTURE_CREATION_FLAG_ON_TILE) { - pCmd->pRenderPassDesc.colorAttachments[i].loadAction = MTLLoadActionDontCare; + pCmd->pRenderPassDesc.colorAttachments[i].loadAction = + (pLoadActions != NULL ? util_to_mtl_load_action(pLoadActions->mLoadActionsColor[i]) : MTLLoadActionDontCare); pCmd->pRenderPassDesc.colorAttachments[i].storeAction = MTLStoreActionDontCare; } else @@ -3284,7 +3264,6 @@ void cmdBindRenderTargets( (pLoadActions != NULL ? util_to_mtl_load_action(pLoadActions->mLoadActionsColor[i]) : MTLLoadActionLoad); pCmd->pRenderPassDesc.colorAttachments[i].storeAction = MTLStoreActionStore; } -#endif if (pLoadActions != NULL) { const ClearValue& clearValue = pLoadActions->mClearColorValues[i]; @@ -3300,61 +3279,45 @@ void cmdBindRenderTargets( pCmd->pRenderPassDesc.depthAttachment.slice = (depthArraySlice != -1 ? depthArraySlice : 0); #ifndef TARGET_IOS bool isStencilEnabled = pDepthStencil->pTexture->mtlPixelFormat == MTLPixelFormatDepth24Unorm_Stencil8; - if (isStencilEnabled) - { - pCmd->pRenderPassDesc.stencilAttachment.texture = pDepthStencil->pTexture->mtlTexture; - pCmd->pRenderPassDesc.stencilAttachment.level = (depthMipSlice != -1 ? depthMipSlice : 0); - pCmd->pRenderPassDesc.stencilAttachment.slice = (depthArraySlice != -1 ? depthArraySlice : 0); - } - - pCmd->pRenderPassDesc.depthAttachment.loadAction = - pLoadActions ? util_to_mtl_load_action(pLoadActions->mLoadActionDepth) : MTLLoadActionClear; - pCmd->pRenderPassDesc.depthAttachment.storeAction = MTLStoreActionStore; - if (isStencilEnabled) - { - pCmd->pRenderPassDesc.stencilAttachment.loadAction = - pLoadActions ? util_to_mtl_load_action(pLoadActions->mLoadActionStencil) : MTLLoadActionDontCare; - pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionStore; - } - else - { - pCmd->pRenderPassDesc.stencilAttachment.loadAction = MTLLoadActionDontCare; - pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionDontCare; - } #else - bool isStencilEnabled = pDepthStencil->pStencil != nil; + bool isStencilEnabled = false; +#endif + isStencilEnabled = isStencilEnabled || pDepthStencil->pTexture->mtlPixelFormat == MTLPixelFormatDepth32Float_Stencil8; if (isStencilEnabled) { - pCmd->pRenderPassDesc.stencilAttachment.texture = pDepthStencil->pStencil->mtlTexture; + pCmd->pRenderPassDesc.stencilAttachment.texture = pDepthStencil->pTexture->mtlTexture; pCmd->pRenderPassDesc.stencilAttachment.level = (depthMipSlice != -1 ? depthMipSlice : 0); pCmd->pRenderPassDesc.stencilAttachment.slice = (depthArraySlice != -1 ? depthArraySlice : 0); } - - if (pDepthStencil->pTexture->mtlTexture.storageMode != MTLStorageModeMemoryless) - { - pCmd->pRenderPassDesc.depthAttachment.loadAction = - pLoadActions ? util_to_mtl_load_action(pLoadActions->mLoadActionDepth) : MTLLoadActionDontCare; - pCmd->pRenderPassDesc.depthAttachment.storeAction = MTLStoreActionStore; - if (isStencilEnabled) - { - pCmd->pRenderPassDesc.stencilAttachment.loadAction = - pLoadActions ? util_to_mtl_load_action(pLoadActions->mLoadActionStencil) : MTLLoadActionDontCare; - pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionStore; - } - else - { - pCmd->pRenderPassDesc.stencilAttachment.loadAction = MTLLoadActionDontCare; - pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionDontCare; - } - } - else - { - pCmd->pRenderPassDesc.depthAttachment.loadAction = MTLLoadActionDontCare; - pCmd->pRenderPassDesc.depthAttachment.storeAction = MTLStoreActionDontCare; - pCmd->pRenderPassDesc.stencilAttachment.loadAction = MTLLoadActionDontCare; - pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionDontCare; - } -#endif + + // For on-tile (memoryless) textures, we never need to load or store. + if (pDepthStencil->pTexture->mDesc.mFlags & TEXTURE_CREATION_FLAG_ON_TILE) + { + pCmd->pRenderPassDesc.depthAttachment.loadAction = + (pLoadActions != NULL ? util_to_mtl_load_action(pLoadActions->mLoadActionDepth) : MTLLoadActionDontCare); + pCmd->pRenderPassDesc.depthAttachment.storeAction = MTLStoreActionDontCare; + pCmd->pRenderPassDesc.stencilAttachment.loadAction = + (pLoadActions != NULL ? util_to_mtl_load_action(pLoadActions->mLoadActionStencil) : MTLLoadActionDontCare); + pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionDontCare; + } + else + { + pCmd->pRenderPassDesc.depthAttachment.loadAction = + pLoadActions ? util_to_mtl_load_action(pLoadActions->mLoadActionDepth) : MTLLoadActionDontCare; + pCmd->pRenderPassDesc.depthAttachment.storeAction = MTLStoreActionStore; + if (isStencilEnabled) + { + pCmd->pRenderPassDesc.stencilAttachment.loadAction = + pLoadActions ? util_to_mtl_load_action(pLoadActions->mLoadActionStencil) : MTLLoadActionDontCare; + pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionStore; + } + else + { + pCmd->pRenderPassDesc.stencilAttachment.loadAction = MTLLoadActionDontCare; + pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionDontCare; + } + } + if (pLoadActions) { pCmd->pRenderPassDesc.depthAttachment.clearDepth = pLoadActions->mClearDepth.depth; @@ -3370,7 +3333,7 @@ void cmdBindRenderTargets( pCmd->pRenderPassDesc.stencilAttachment.storeAction = MTLStoreActionDontCare; } - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); pCmd->mtlRenderEncoder = [pCmd->mtlCommandBuffer renderCommandEncoderWithDescriptor:pCmd->pRenderPassDesc]; pCmd->mRenderPassActive = true; @@ -3470,7 +3433,7 @@ void cmdBindPipeline(Cmd* pCmd, Pipeline* pPipeline) { if (!pCmd->mtlComputeEncoder) { - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); pCmd->mtlComputeEncoder = [pCmd->mtlCommandBuffer computeCommandEncoder]; } [pCmd->mtlComputeEncoder setComputePipelineState:pPipeline->mtlComputePipelineState]; @@ -3479,7 +3442,7 @@ void cmdBindPipeline(Cmd* pCmd, Pipeline* pPipeline) { if (!pCmd->mtlComputeEncoder) { - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); pCmd->mtlComputeEncoder = [pCmd->mtlCommandBuffer computeCommandEncoder]; } } @@ -3824,7 +3787,8 @@ void cmdResourceBarrier(Cmd* pCmd, uint32_t numBufferBarriers, BufferBarrier* pB pTrans->mNewState == RESOURCE_STATE_RENDER_TARGET || pTexture->mCurrentState == RESOURCE_STATE_DEPTH_WRITE || pTexture->mCurrentState == RESOURCE_STATE_DEPTH_READ || - pTexture->mCurrentState == RESOURCE_STATE_RENDER_TARGET) + pTexture->mCurrentState == RESOURCE_STATE_RENDER_TARGET || + pTexture->mCurrentState == RESOURCE_STATE_PRESENT) { pCmd->pCmdPool->pQueue->mBarrierFlags |= BARRIER_FLAG_RENDERTARGETS; } @@ -3846,7 +3810,7 @@ void cmdUpdateBuffer(Cmd* pCmd, Buffer* pBuffer, uint64_t dstOffset, Buffer* pSr ASSERT(srcOffset + size <= pSrcBuffer->mDesc.mSize); ASSERT(dstOffset + size <= pBuffer->mDesc.mSize); - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); pCmd->mtlBlitEncoder = [pCmd->mtlCommandBuffer blitCommandEncoder]; util_barrier_required(pCmd, CMD_POOL_COPY); @@ -3860,7 +3824,7 @@ void cmdUpdateBuffer(Cmd* pCmd, Buffer* pBuffer, uint64_t dstOffset, Buffer* pSr void cmdUpdateSubresource(Cmd* pCmd, Texture* pTexture, Buffer* pIntermediate, SubresourceDataDesc* pSubresourceDesc) { - util_end_current_encoders(pCmd); + util_end_current_encoders(pCmd, false); pCmd->mtlBlitEncoder = [pCmd->mtlCommandBuffer blitCommandEncoder]; util_barrier_required(pCmd, CMD_POOL_COPY); @@ -4002,7 +3966,7 @@ void queueSubmit( } // Commit any uncommited encoder. This is necessary before committing the command buffer - util_end_current_encoders(ppCmds[i]); + util_end_current_encoders(ppCmds[i], false); [ppCmds[i]->mtlCommandBuffer commit]; } } @@ -4201,16 +4165,26 @@ uint64_t util_pthread_to_uint64(const pthread_t& value) } -bool util_is_mtl_depth_pixel_format(const MTLPixelFormat& format) +bool util_is_mtl_depth_pixel_format(const MTLPixelFormat format) { - return format == MTLPixelFormatDepth32Float || format == MTLPixelFormatDepth32Float_Stencil8 -#ifndef TARGET_IOS - || format == MTLPixelFormatDepth16Unorm || format == MTLPixelFormatDepth24Unorm_Stencil8 + if (format == MTLPixelFormatDepth32Float || format == MTLPixelFormatDepth32Float_Stencil8) + return true; + +#ifdef TARGET_IOS + if (@available(iOS 13, *)) + { + if (format == MTLPixelFormatDepth16Unorm) + return true; + } +#else + if (format == MTLPixelFormatDepth16Unorm || format == MTLPixelFormatDepth24Unorm_Stencil8) + return true; #endif - ; + + return false; } -bool util_is_mtl_compressed_pixel_format(const MTLPixelFormat& format) +bool util_is_mtl_compressed_pixel_format(const MTLPixelFormat format) { #ifndef TARGET_IOS return format >= MTLPixelFormatBC1_RGBA; @@ -4219,7 +4193,7 @@ bool util_is_mtl_compressed_pixel_format(const MTLPixelFormat& format) #endif } -MTLVertexFormat util_to_mtl_vertex_format(const TinyImageFormat& format) +MTLVertexFormat util_to_mtl_vertex_format(const TinyImageFormat format) { switch (format) { @@ -4274,7 +4248,7 @@ MTLVertexFormat util_to_mtl_vertex_format(const TinyImageFormat& format) return MTLVertexFormatInvalid; } -MTLLoadAction util_to_mtl_load_action(const LoadActionType& loadActionType) +MTLLoadAction util_to_mtl_load_action(const LoadActionType loadActionType) { if (loadActionType == LOAD_ACTION_DONTCARE) return MTLLoadActionDontCare; @@ -4420,7 +4394,7 @@ void util_bind_argument_buffer(Cmd* pCmd, DescriptorBinderNode& node, const Desc } */ -void util_end_current_encoders(Cmd* pCmd) +void util_end_current_encoders(Cmd* pCmd, bool forceBarrier) { const bool barrierRequired(pCmd->pCmdPool->pQueue->mBarrierFlags); @@ -4428,7 +4402,7 @@ void util_end_current_encoders(Cmd* pCmd) { ASSERT(pCmd->mtlComputeEncoder == nil && pCmd->mtlBlitEncoder == nil); - if (barrierRequired) + if (barrierRequired || forceBarrier) { [pCmd->mtlRenderEncoder updateFence:pCmd->mtlEncoderFence afterStages:MTLRenderStageFragment]; pCmd->pCmdPool->pQueue->mBarrierFlags |= BARRIER_FLAG_FENCE; @@ -4584,14 +4558,13 @@ void add_texture(Renderer* pRenderer, const TextureDesc* pDesc, Texture** ppText pTexture->mDesc = *pDesc; pTexture->mtlPixelFormat = (MTLPixelFormat) TinyImageFormat_ToMTLPixelFormat(pTexture->mDesc.mFormat); -#ifndef TARGET_IOS - if (pTexture->mtlPixelFormat == MTLPixelFormatDepth24Unorm_Stencil8 && ![pRenderer->pDevice isDepth24Stencil8PixelFormatSupported]) - { - internal_log(LOG_TYPE_WARN, "Format D24S8 is not supported on this device. Using D32 instead", "addTexture"); - pTexture->mtlPixelFormat = MTLPixelFormatDepth32Float; - pTexture->mDesc.mFormat = TinyImageFormat_D32_SFLOAT; + + if (pTexture->mDesc.mFormat == TinyImageFormat_D24_UNORM_S8_UINT && !pRenderer->capBits.canRenderTargetWriteTo[pTexture->mDesc.mFormat]) + { + internal_log(LOG_TYPE_WARN, "Format D24S8 is not supported on this device. Using D32S8 instead", "addTexture"); + pTexture->mtlPixelFormat = MTLPixelFormatDepth32Float_Stencil8; + pTexture->mDesc.mFormat = TinyImageFormat_D32_SFLOAT_S8_UINT; } -#endif pTexture->mIsCompressed = util_is_mtl_compressed_pixel_format(pTexture->mtlPixelFormat); pTexture->mTextureSize = pTexture->mDesc.mArraySize * Image_GetMipMappedSize( diff --git a/Common_3/Renderer/ResourceLoader.cpp b/Common_3/Renderer/ResourceLoader.cpp index 299e374e69..49184a3f45 100644 --- a/Common_3/Renderer/ResourceLoader.cpp +++ b/Common_3/Renderer/ResourceLoader.cpp @@ -815,7 +815,8 @@ static void streamerThreadFunc(void* pThreadData) while (pLoader->mRun && (completionMask == allUploadsCompleted) && allQueuesEmpty(pLoader) && getSystemTime() < nextTimeslot) { unsigned time = getSystemTime(); - pLoader->mQueueCond.Wait(pLoader->mQueueMutex, nextTimeslot - time); + unsigned nextSlot = min(nextTimeslot - time, pLoader->mDesc.mTimesliceMs); + pLoader->mQueueCond.Wait(pLoader->mQueueMutex, nextSlot); } pLoader->mQueueMutex.Release(); @@ -1209,6 +1210,7 @@ void updateResource(TextureUpdateDesc* pTextureUpdate, SyncToken* token) Image* pImage = ResourceLoader::CreateImage(pTextureUpdate->pRawImageData->mFormat, pTextureUpdate->pRawImageData->mWidth, pTextureUpdate->pRawImageData->mHeight, pTextureUpdate->pRawImageData->mDepth, pTextureUpdate->pRawImageData->mMipLevels, pTextureUpdate->pRawImageData->mArraySize, pTextureUpdate->pRawImageData->pRawData); + pImage->SetMipsAfterSlices(pTextureUpdate->pRawImageData->mMipsAfterSlices); desc.mFreeImage = true; desc.pImage = pImage; } diff --git a/Common_3/Renderer/Vulkan/VulkanCapsBuilder.h b/Common_3/Renderer/Vulkan/VulkanCapsBuilder.h index cac9200465..5a73e903f8 100644 --- a/Common_3/Renderer/Vulkan/VulkanCapsBuilder.h +++ b/Common_3/Renderer/Vulkan/VulkanCapsBuilder.h @@ -5,7 +5,7 @@ inline void utils_caps_builder(Renderer* pRenderer) { memset(pRenderer->capBits.canShaderReadFrom, 0, sizeof(pRenderer->capBits.canShaderReadFrom)); memset(pRenderer->capBits.canShaderWriteTo, 0, sizeof(pRenderer->capBits.canShaderWriteTo)); - memset(pRenderer->capBits.canColorWriteTo, 0, sizeof(pRenderer->capBits.canColorWriteTo)); + memset(pRenderer->capBits.canRenderTargetWriteTo, 0, sizeof(pRenderer->capBits.canRenderTargetWriteTo)); for (uint32_t i = 0; i < TinyImageFormat_Count;++i) { VkFormatProperties formatSupport; @@ -17,8 +17,9 @@ inline void utils_caps_builder(Renderer* pRenderer) { (formatSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0; pRenderer->capBits.canShaderWriteTo[i] = (formatSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0; - pRenderer->capBits.canColorWriteTo[i] = - (formatSupport.optimalTilingFeatures & VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) != 0; + pRenderer->capBits.canRenderTargetWriteTo[i] = + (formatSupport.optimalTilingFeatures & + (VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) != 0; } } diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/common.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/common.hpp index 576dcca0f9..7471fd93ec 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/common.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/common.hpp @@ -864,6 +864,31 @@ inline Vector3 max(const Vector3 &a, const Vector3 &b) #endif } +inline Vector4 min(const Vector4& a, const Vector4& b) +{ +#if VECTORMATH_MODE_SCALAR + return Vector3( + min(a.getX(), b.getX()), + min(a.getY(), b.getY()), + min(a.getZ(), b.getZ()), + min(a.getW(), b.getW())); +#else + return Vector4(_mm_min_ps(a.get128(), b.get128())); +#endif +} +inline Vector4 max(const Vector4& a, const Vector4& b) +{ +#if VECTORMATH_MODE_SCALAR + return Vector3( + max(a.getX(), b.getX()), + max(a.getY(), b.getY()), + max(a.getZ(), b.getZ()), + max(a.getW(), b.getW())); +#else + return Vector4(_mm_max_ps(a.get128(), b.get128())); +#endif +} + inline Vector3 lerp(const Vector3 &u, const Vector3 &v, const float x) { return u + x * (v - u); } inline Vector3 clamp(const Vector3 &v, const Vector3 &c0, const Vector3 &c1) { return min(max(v, c0), c1); } diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/boolinvec.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/boolinvec.hpp index 506956081c..e8e945045a 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/boolinvec.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/boolinvec.hpp @@ -36,6 +36,7 @@ namespace Neon { class FloatInVec; +typedef __m128i Vector4Int; // ======================================================== // BoolInVec @@ -92,6 +93,7 @@ VECTORMATH_ALIGNED_TYPE_PRE class BoolInVec friend inline const BoolInVec operator == (const FloatInVec & vec0, const FloatInVec & vec1); friend inline const BoolInVec operator != (const FloatInVec & vec0, const FloatInVec & vec1); friend inline const BoolInVec operator & (const BoolInVec & vec0, const BoolInVec & vec1); + friend inline const Vector4Int operator & (const BoolInVec & vec0, const Vector4Int & vec1); friend inline const BoolInVec operator ^ (const BoolInVec & vec0, const BoolInVec & vec1); friend inline const BoolInVec operator | (const BoolInVec & vec0, const BoolInVec & vec1); friend inline const BoolInVec select(const BoolInVec & vec0, const BoolInVec & vec1, const BoolInVec & select_vec1); @@ -107,6 +109,7 @@ VECTORMATH_ALIGNED_TYPE_PRE class BoolInVec inline const BoolInVec operator == (const BoolInVec & vec0, const BoolInVec & vec1); inline const BoolInVec operator != (const BoolInVec & vec0, const BoolInVec & vec1); inline const BoolInVec operator & (const BoolInVec & vec0, const BoolInVec & vec1); +inline const Vector4Int operator & (const BoolInVec & vec0, const Vector4Int& vec1); inline const BoolInVec operator ^ (const BoolInVec & vec0, const BoolInVec & vec1); inline const BoolInVec operator | (const BoolInVec & vec0, const BoolInVec & vec1); @@ -209,6 +212,11 @@ inline const BoolInVec operator & (const BoolInVec & vec0, const BoolInVec & vec return BoolInVec(_mm_and_ps(vec0.get128(), vec1.get128())); } +inline const Vector4Int operator & (const BoolInVec& vec0, const Vector4Int& vec1) +{ + return _mm_and_si128(_mm_castps_si128(vec0.get128()), vec1); +} + inline const BoolInVec operator | (const BoolInVec & vec0, const BoolInVec & vec1) { return BoolInVec(_mm_or_ps(vec0.get128(), vec1.get128())); diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/floatinvec.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/floatinvec.hpp index 37af0d956c..6428911b98 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/floatinvec.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/floatinvec.hpp @@ -36,6 +36,7 @@ namespace Neon { class BoolInVec; +typedef __m128i Vector4Int; // ======================================================== // FloatInVec @@ -121,6 +122,13 @@ inline const BoolInVec operator != (const FloatInVec & vec0, const FloatInVec & // inline const FloatInVec select(const FloatInVec & vec0, const FloatInVec & vec1, const BoolInVec & select_vec1); +inline const FloatInVec rcpEst(const FloatInVec& v); +inline const FloatInVec rSqrtEstNR(const FloatInVec& v); +inline const FloatInVec sqrt(const FloatInVec& v); +inline const FloatInVec xorPerElem(const FloatInVec& a, const Vector4Int b); +inline const FloatInVec andPerElem(const FloatInVec& a, const Vector4Int b); +inline const FloatInVec andNotPerElem(const FloatInVec& a, const Vector4Int b); + } // namespace Neon } // namespace Vectormath @@ -287,6 +295,41 @@ inline const FloatInVec select(const FloatInVec & vec0, const FloatInVec & vec1, return FloatInVec(sseSelect(vec0.get128(), vec1.get128(), select_vec1.get128())); } +inline const FloatInVec rcpEst(const FloatInVec& v) +{ + return FloatInVec(_mm_rcp_ps(v.get128())); +} + +inline const FloatInVec rSqrtEstNR(const FloatInVec& v) +{ + const __m128 nr = _mm_rsqrt_ps(v.get128()); + // Do one more Newton-Raphson step to improve precision. + const __m128 muls = _mm_mul_ps(_mm_mul_ps(v.get128(), nr), nr); + return FloatInVec(_mm_mul_ps(_mm_mul_ps(_mm_set_ps1(.5f), nr), _mm_sub_ps(_mm_set_ps1(3.f), muls))); +} + +inline const FloatInVec sqrt(const FloatInVec& v) +{ + return FloatInVec(_mm_sqrt_ps(v.get128())); +} + +inline const FloatInVec xorPerElem(const FloatInVec &a, const Vector4Int b) +{ + return FloatInVec(_mm_xor_ps(a.get128(), _mm_castsi128_ps(b))); +} + +inline const FloatInVec andPerElem(const FloatInVec& a, const Vector4Int b) +{ + return FloatInVec(_mm_and_ps(a.get128(), _mm_castsi128_ps(b))); +} + +inline const FloatInVec andNotPerElem(const FloatInVec& a, const Vector4Int b) +{ + return FloatInVec(_mm_andnot_ps(a.get128(), _mm_castsi128_ps(b))); +} + + + } // namespace Neon } // namespace Vectormath diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/quaternion.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/quaternion.hpp index 9123f8d6a8..5407b686c1 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/quaternion.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/quaternion.hpp @@ -436,6 +436,61 @@ inline const Quat Quat::rotationZ(const FloatInVec & radians) return Quat(res); } +inline const Quat Quat::fromVectors(const Vector3& from, const Vector3& to) +{ + const __m128 from_128 = from.get128(); + const __m128 to_128 = to.get128(); + + const __m128 norm_from_norm_to = + _mm_sqrt_ss(_mm_mul_ps(sseVecDot3(from_128, from_128), sseVecDot3(to_128, to_128))); + const float norm_from_norm_to_x = _mm_cvtss_f32(norm_from_norm_to); + if (norm_from_norm_to_x < kNormalizationToleranceSq) { + return Quat::identity(); + } + + const __m128 real_part = _mm_add_ss(norm_from_norm_to, dot(from, to).get128()); + __m128 quat; + if (_mm_cvtss_f32(real_part) < kNormalizationToleranceSq * norm_from_norm_to_x) { + // If _from and _to are exactly opposite, rotate 180 degrees around an + // arbitrary orthogonal axis. Axis normalization can happen later, when we + // normalize the quaternion. + + float from_f[4]; + _mm_storeu_ps(from_f, from_128); + quat = std::abs(from_f[0]) > std::abs(from_f[2]) + ? _mm_set_ps(0.0f, 0.0f, from_f[0], -from_f[1]) + : _mm_set_ps(0.0f, from_f[1], -from_f[2], 0.0f); + } + else { + // This is the general code path. + quat = sseVecCross(from_128, to_128); + quat = _mm_shuffle_ps(quat, _mm_shuffle_ps(real_part, quat, _MM_SHUFFLE(2, 2, 0, 0)), _MM_SHUFFLE(0, 2, 1, 0)); + } + + return Quat(normalize(Vector4(quat))); +} + +inline const Quat Quat::fromAxisCosAngle(const Vector3 &axis, const FloatInVec &cos) +{ + + const __m128 one = _mm_set1_ps(1.0f); + const __m128 half = _mm_set1_ps(0.5f); + + const __m128 half_cos2 = _mm_mul_ps(_mm_add_ps(one, cos.get128()), half); + const __m128 half_sin2 = _mm_sub_ps(one, half_cos2); + const __m128 half_sincos2 = + _mm_shuffle_ps(_mm_unpacklo_ps(half_cos2, half_sin2), half_cos2, + _MM_SHUFFLE(3, 2, 1, 0)); + const __m128 half_sincos = _mm_sqrt_ps(half_sincos2); + const __m128 half_sin = sseSplat(half_sincos, 1); + + const __m128 vec = _mm_mul_ps(axis.get128(), half_sin); + + return Quat(_mm_shuffle_ps( + vec, _mm_shuffle_ps(half_sincos, vec, _MM_SHUFFLE(2, 2, 0, 0)), + _MM_SHUFFLE(0, 2, 1, 0))); +} + inline const Quat Quat::operator * (const Quat & quat) const { __m128 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/sse2neon.h b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/sse2neon.h index a3f2b7f7a2..ee7673689a 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/sse2neon.h +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/sse2neon.h @@ -1252,7 +1252,7 @@ FORCE_INLINE __m128 _mm_cmplt_ps(__m128 a, __m128 b) FORCE_INLINE __m128 _mm_cmplt_ss(__m128 a, __m128 b) { - return vsetq_lane_f32((_mm_cmplt_ps(a, b), 0), vreinterpretq_f32_m128(a), 0); + return vsetq_lane_f32(vgetq_lane_f32(_mm_cmplt_ps(a, b), 0), vreinterpretq_f32_m128(a), 0); } // Compares for greater than. https://msdn.microsoft.com/en-us/library/vstudio/11dy102s(v=vs.100).aspx @@ -1261,6 +1261,11 @@ FORCE_INLINE __m128 _mm_cmpgt_ps(__m128 a, __m128 b) return vreinterpretq_m128_u32(vcgtq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); } +FORCE_INLINE __m128 _mm_cmpgt_ss(__m128 a, __m128 b) +{ + return vsetq_lane_f32(vgetq_lane_f32(_mm_cmpgt_ps(a, b), 0), vreinterpretq_f32_m128(a), 0); +} + // Compares for greater than or equal. https://msdn.microsoft.com/en-us/library/vstudio/fs813y2t(v=vs.100).aspx FORCE_INLINE __m128 _mm_cmpge_ps(__m128 a, __m128 b) { @@ -1684,7 +1689,7 @@ FORCE_INLINE __m128 _mm_movehl_ps(__m128 a, __m128 b) { // Move the lower single-precision (32-bit) floating-point element from b to the lower element of dst, and copy the upper 3 elements from a to the upper elements of dst. // https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_move_ss&expand=5217,3606,3720,5595,3828 FORCE_INLINE __m128 _mm_move_ss(__m128 a, __m128 b) { - return __builtin_shufflevector(a, b, 0, 5, 6, 7); + return __builtin_shufflevector(b, a, 0, 5, 6, 7); } // Negate packed 32-bit integers in a when the corresponding signed 32-bit integer in b is negative, and store the results in dst. Element in dst are zeroed out when the corresponding element in b is zero. diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vector.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vector.hpp index 9d2367893a..4c8f631a74 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vector.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vector.hpp @@ -505,6 +505,33 @@ inline const Vector3 select(const Vector3 & vec0, const Vector3 & vec1, const Bo return Vector3(sseSelect(vec0.get128(), vec1.get128(), select1.get128())); } +inline const Vector3 xorPerElem(const Vector3& a, const FloatInVec b) +{ + return Vector3(_mm_xor_ps(a.get128(), b.get128())); +} + +inline const Vector3 sqrtPerElem(const Vector3 & vec) +{ + return Vector3(_mm_sqrt_ps(vec.get128())); +} + +inline const Vector3 rSqrtEstNR(const Vector3& v) +{ + const __m128 nr = _mm_rsqrt_ps(v.get128()); + // Do one more Newton-Raphson step to improve precision. + const __m128 muls = _mm_mul_ps(_mm_mul_ps(v.get128(), nr), nr); + return Vector3(_mm_mul_ps(_mm_mul_ps(_mm_set_ps1(.5f), nr), _mm_sub_ps(_mm_set_ps1(3.f), muls))); +} + +inline bool isNormalizedEst(const Vector3& v) { + const __m128 max = _mm_set_ss(1.f + kNormalizationToleranceEstSq); + const __m128 min = _mm_set_ss(1.f - kNormalizationToleranceEstSq); + const __m128 dot = sseVecDot3(v.get128(), v.get128()); + const __m128 dotx000 = _mm_move_ss(_mm_setzero_ps(), dot); + return (_mm_movemask_ps( + _mm_and_ps(_mm_cmplt_ss(dotx000, max), _mm_cmpgt_ss(dotx000, min))) & 0x1) == 0x1; +} + #ifdef VECTORMATH_DEBUG inline void print(const Vector3 & vec) @@ -905,6 +932,11 @@ inline const Vector4 rSqrtEstNR(const Vector4& v) { return Vector4(_mm_mul_ps(_mm_mul_ps(_mm_set_ps1(.5f), nr), _mm_sub_ps(_mm_set_ps1(3.f), muls))); } +inline const Vector4 aCos(const Vector4& arg) +{ + return Vector4(sseACosf(arg.get128())); +} + //========================================= #ConfettiAnimationMathExtensionsEnd ======================================= //========================================= #ConfettiMathExtensionsEnd ================================================ @@ -1854,6 +1886,10 @@ inline Vector4Int And(const Vector4Int _a, const Vector4Int _b) { return _mm_and_si128(_a, _b); } +inline Vector4Int And(const Vector4Int& a, const BoolInVec b) { + return _mm_and_si128(a, _mm_castps_si128(b.get128())); +} + inline Vector4Int Or(const Vector4Int _a, const Vector4Int _b) { return _mm_or_si128(_a, _b); } diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vectormath.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vectormath.hpp index 7c0781d228..85f56c221a 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vectormath.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/neon/vectormath.hpp @@ -88,6 +88,9 @@ typedef __m128i Vector4Int; typedef const __m128i _Vector4Int; +static const float kNormalizationToleranceSq = 1e-6f; +static const float kNormalizationToleranceEstSq = 2e-3f; + //========================================= #ConfettiAnimationMathExtensionsEnd ======================================= //========================================= #ConfettiMathExtensionsEnd ================================================ @@ -416,6 +419,24 @@ inline const Vector3 select(const Vector3 & vec0, const Vector3 & vec1, bool sel // inline const Vector3 select(const Vector3 & vec0, const Vector3 & vec1, const BoolInVec & select1); +// Returns per element binary logical xor operation of _a and _b. +// _v[0...127] = _a[0...127] ^ _b[0...127] +// +inline const Vector3 xorPerElem(const Vector3& a, const FloatInVec b); + +// Compute the squareroot of a 3-D vector per element +// +inline const Vector3 sqrtPerElem(const Vector3& vec); + +// Returns the per component estimated reciprocal square root of v, where +// approximation is improved with one more new Newton-Raphson step. +// +inline const Vector3 rSqrtEstNR(const Vector3& v); + +// Tests if the components x, y and z of _v forms a normalized vector. +// +inline bool isNormalizedEst(const Vector3& v); + // Store x, y, and z elements of 3-D vector in first three words of a quadword, preserving fourth word // inline void storeXYZ(const Vector3 & vec, __m128 * quad); @@ -730,6 +751,10 @@ inline const Vector4 rSqrtEst(const Vector4& v); // inline const Vector4 rSqrtEstNR(const Vector4& v); +// Computes the per element arccosine +// +inline const Vector4 aCos(const Vector4& arg); + //========================================= #ConfettiAnimationMathExtensionsEnd ======================================= //========================================= #ConfettiMathExtensionsEnd ================================================ @@ -1425,6 +1450,10 @@ VECTORMATH_ALIGNED_TYPE_PRE class Quat // static inline const Quat rotationZ(const FloatInVec & radians); + static inline const Quat fromVectors(const Vector3& from, const Vector3& to); + + static inline const Quat fromAxisCosAngle(const Vector3& axis, const FloatInVec& cos); + } VECTORMATH_ALIGNED_TYPE_POST; // Multiply a quaternion by a scalar @@ -2843,6 +2872,10 @@ inline Vector4Int Select(const Vector4Int _b, const Vector4Int _true, const Vect // _v[0...127] = _a[0...127] & _b[0...127] inline Vector4Int And(const Vector4Int _a, const Vector4Int _b); +// Returns per element binary and operation of _a and _b. +// _v[0...127] = _a[0...127] & _b[0...127] +inline Vector4Int And(const Vector4Int& a, const BoolInVec b); + // Returns per element binary or operation of _a and _b. // _v[0...127] = _a[0...127] | _b[0...127] inline Vector4Int Or(const Vector4Int _a, const Vector4Int _b); diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/boolinvec.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/boolinvec.hpp index d2510dcbc7..aa47676206 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/boolinvec.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/boolinvec.hpp @@ -36,6 +36,7 @@ namespace SSE { class FloatInVec; +typedef __m128i Vector4Int; // ======================================================== // BoolInVec @@ -92,6 +93,7 @@ VECTORMATH_ALIGNED_TYPE_PRE class BoolInVec friend inline const BoolInVec operator == (const FloatInVec & vec0, const FloatInVec & vec1); friend inline const BoolInVec operator != (const FloatInVec & vec0, const FloatInVec & vec1); friend inline const BoolInVec operator & (const BoolInVec & vec0, const BoolInVec & vec1); + friend inline const Vector4Int operator & (const BoolInVec & vec0, const Vector4Int & vec1); friend inline const BoolInVec operator ^ (const BoolInVec & vec0, const BoolInVec & vec1); friend inline const BoolInVec operator | (const BoolInVec & vec0, const BoolInVec & vec1); friend inline const BoolInVec select(const BoolInVec & vec0, const BoolInVec & vec1, const BoolInVec & select_vec1); @@ -107,6 +109,7 @@ VECTORMATH_ALIGNED_TYPE_PRE class BoolInVec inline const BoolInVec operator == (const BoolInVec & vec0, const BoolInVec & vec1); inline const BoolInVec operator != (const BoolInVec & vec0, const BoolInVec & vec1); inline const BoolInVec operator & (const BoolInVec & vec0, const BoolInVec & vec1); +inline const Vector4Int operator & (const BoolInVec & vec0, const Vector4Int& vec1); inline const BoolInVec operator ^ (const BoolInVec & vec0, const BoolInVec & vec1); inline const BoolInVec operator | (const BoolInVec & vec0, const BoolInVec & vec1); @@ -209,6 +212,11 @@ inline const BoolInVec operator & (const BoolInVec & vec0, const BoolInVec & vec return BoolInVec(_mm_and_ps(vec0.get128(), vec1.get128())); } +inline const Vector4Int operator & (const BoolInVec& vec0, const Vector4Int& vec1) +{ + return _mm_and_si128(_mm_castps_si128(vec0.get128()), vec1); +} + inline const BoolInVec operator | (const BoolInVec & vec0, const BoolInVec & vec1) { return BoolInVec(_mm_or_ps(vec0.get128(), vec1.get128())); diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/floatinvec.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/floatinvec.hpp index c56e97bec8..932bb239fd 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/floatinvec.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/floatinvec.hpp @@ -36,6 +36,7 @@ namespace SSE { class BoolInVec; +typedef __m128i Vector4Int; // ======================================================== // FloatInVec @@ -121,6 +122,13 @@ inline const BoolInVec operator != (const FloatInVec & vec0, const FloatInVec & // inline const FloatInVec select(const FloatInVec & vec0, const FloatInVec & vec1, const BoolInVec & select_vec1); +inline const FloatInVec rcpEst(const FloatInVec& v); +inline const FloatInVec rSqrtEstNR(const FloatInVec& v); +inline const FloatInVec sqrt(const FloatInVec& v); +inline const FloatInVec xorPerElem(const FloatInVec& a, const Vector4Int b); +inline const FloatInVec andPerElem(const FloatInVec& a, const Vector4Int b); +inline const FloatInVec andNotPerElem(const FloatInVec& a, const Vector4Int b); + } // namespace SSE } // namespace Vectormath @@ -287,6 +295,39 @@ inline const FloatInVec select(const FloatInVec & vec0, const FloatInVec & vec1, return FloatInVec(sseSelect(vec0.get128(), vec1.get128(), select_vec1.get128())); } +inline const FloatInVec rcpEst(const FloatInVec& v) +{ + return FloatInVec(_mm_rcp_ps(v.get128())); +} + +inline const FloatInVec rSqrtEstNR(const FloatInVec& v) +{ + const __m128 nr = _mm_rsqrt_ps(v.get128()); + // Do one more Newton-Raphson step to improve precision. + const __m128 muls = _mm_mul_ps(_mm_mul_ps(v.get128(), nr), nr); + return FloatInVec(_mm_mul_ps(_mm_mul_ps(_mm_set_ps1(.5f), nr), _mm_sub_ps(_mm_set_ps1(3.f), muls))); +} + +inline const FloatInVec sqrt(const FloatInVec& v) +{ + return FloatInVec(_mm_sqrt_ps(v.get128())); +} + +inline const FloatInVec xorPerElem(const FloatInVec &a, const Vector4Int b) +{ + return FloatInVec(_mm_xor_ps(a.get128(), _mm_castsi128_ps(b))); +} + +inline const FloatInVec andPerElem(const FloatInVec& a, const Vector4Int b) +{ + return FloatInVec(_mm_and_ps(a.get128(), _mm_castsi128_ps(b))); +} + +inline const FloatInVec andNotPerElem(const FloatInVec& a, const Vector4Int b) +{ + return FloatInVec(_mm_andnot_ps(a.get128(), _mm_castsi128_ps(b))); +} + } // namespace SSE } // namespace Vectormath diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/quaternion.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/quaternion.hpp index 3cb5f686bb..b5c94c32d6 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/quaternion.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/quaternion.hpp @@ -436,6 +436,61 @@ inline const Quat Quat::rotationZ(const FloatInVec & radians) return Quat(res); } +inline const Quat Quat::fromVectors(const Vector3& from, const Vector3& to) +{ + const __m128 from_128 = from.get128(); + const __m128 to_128 = to.get128(); + + const __m128 norm_from_norm_to = + _mm_sqrt_ss(_mm_mul_ps(sseVecDot3(from_128, from_128), sseVecDot3(to_128, to_128))); + const float norm_from_norm_to_x = _mm_cvtss_f32(norm_from_norm_to); + if (norm_from_norm_to_x < kNormalizationToleranceSq) { + return Quat::identity(); + } + + const __m128 real_part = _mm_add_ss(norm_from_norm_to, dot(from, to).get128()); + __m128 quat; + if (_mm_cvtss_f32(real_part) < kNormalizationToleranceSq * norm_from_norm_to_x) { + // If _from and _to are exactly opposite, rotate 180 degrees around an + // arbitrary orthogonal axis. Axis normalization can happen later, when we + // normalize the quaternion. + + float from_f[4]; + _mm_storeu_ps(from_f, from_128); + quat = std::abs(from_f[0]) > std::abs(from_f[2]) + ? _mm_set_ps(0.0f, 0.0f, from_f[0], -from_f[1]) + : _mm_set_ps(0.0f, from_f[1], -from_f[2], 0.0f); + } + else { + // This is the general code path. + quat = sseVecCross(from_128, to_128); + quat = _mm_shuffle_ps(quat, _mm_shuffle_ps(real_part, quat, _MM_SHUFFLE(2, 2, 0, 0)), _MM_SHUFFLE(0, 2, 1, 0)); + } + + return Quat(normalize(Vector4(quat))); +} + +inline const Quat Quat::fromAxisCosAngle(const Vector3 &axis, const FloatInVec &cos) +{ + + const __m128 one = _mm_set1_ps(1.0f); + const __m128 half = _mm_set1_ps(0.5f); + + const __m128 half_cos2 = _mm_mul_ps(_mm_add_ps(one, cos.get128()), half); + const __m128 half_sin2 = _mm_sub_ps(one, half_cos2); + const __m128 half_sincos2 = + _mm_shuffle_ps(_mm_unpacklo_ps(half_cos2, half_sin2), half_cos2, + _MM_SHUFFLE(3, 2, 1, 0)); + const __m128 half_sincos = _mm_sqrt_ps(half_sincos2); + const __m128 half_sin = sseSplat(half_sincos, 1); + + const __m128 vec = _mm_mul_ps(axis.get128(), half_sin); + + return Quat(_mm_shuffle_ps( + vec, _mm_shuffle_ps(half_sincos, vec, _MM_SHUFFLE(2, 2, 0, 0)), + _MM_SHUFFLE(0, 2, 1, 0))); +} + inline const Quat Quat::operator * (const Quat & quat) const { __m128 ldata, rdata, qv, tmp0, tmp1, tmp2, tmp3; diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vector.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vector.hpp index 5b42455baa..e81b258b4b 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vector.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vector.hpp @@ -505,6 +505,33 @@ inline const Vector3 select(const Vector3 & vec0, const Vector3 & vec1, const Bo return Vector3(sseSelect(vec0.get128(), vec1.get128(), select1.get128())); } +inline const Vector3 xorPerElem(const Vector3& a, const FloatInVec b) +{ + return Vector3(_mm_xor_ps(a.get128(), b.get128())); +} + +inline const Vector3 sqrtPerElem(const Vector3 & vec) +{ + return Vector3(_mm_sqrt_ps(vec.get128())); +} + +inline const Vector3 rSqrtEstNR(const Vector3& v) +{ + const __m128 nr = _mm_rsqrt_ps(v.get128()); + // Do one more Newton-Raphson step to improve precision. + const __m128 muls = _mm_mul_ps(_mm_mul_ps(v.get128(), nr), nr); + return Vector3(_mm_mul_ps(_mm_mul_ps(_mm_set_ps1(.5f), nr), _mm_sub_ps(_mm_set_ps1(3.f), muls))); +} + +inline bool isNormalizedEst(const Vector3& v) { + const __m128 max = _mm_set_ss(1.f + kNormalizationToleranceEstSq); + const __m128 min = _mm_set_ss(1.f - kNormalizationToleranceEstSq); + const __m128 dot = sseVecDot3(v.get128(), v.get128()); + const __m128 dotx000 = _mm_move_ss(_mm_setzero_ps(), dot); + return (_mm_movemask_ps( + _mm_and_ps(_mm_cmplt_ss(dotx000, max), _mm_cmpgt_ss(dotx000, min))) & 0x1) == 0x1; +} + #ifdef VECTORMATH_DEBUG inline void print(const Vector3 & vec) @@ -905,6 +932,11 @@ inline const Vector4 rSqrtEstNR(const Vector4& v) { return Vector4(_mm_mul_ps(_mm_mul_ps(_mm_set_ps1(.5f), nr), _mm_sub_ps(_mm_set_ps1(3.f), muls))); } +inline const Vector4 aCos(const Vector4& arg) +{ + return Vector4(sseACosf(arg.get128())); +} + //========================================= #ConfettiAnimationMathExtensionsEnd ======================================= //========================================= #ConfettiMathExtensionsEnd ================================================ @@ -1854,6 +1886,10 @@ inline Vector4Int And(const Vector4Int _a, const Vector4Int _b) { return _mm_and_si128(_a, _b); } +inline Vector4Int And(const Vector4Int& a, const BoolInVec b) { + return _mm_and_si128(a, _mm_castps_si128(b.get128())); +} + inline Vector4Int Or(const Vector4Int _a, const Vector4Int _b) { return _mm_or_si128(_a, _b); } diff --git a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vectormath.hpp b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vectormath.hpp index 10ba96bfff..eab776ae1e 100644 --- a/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vectormath.hpp +++ b/Common_3/ThirdParty/OpenSource/ModifiedSonyMath/sse/vectormath.hpp @@ -88,6 +88,9 @@ typedef __m128i Vector4Int; typedef const __m128i _Vector4Int; +static const float kNormalizationToleranceSq = 1e-6f; +static const float kNormalizationToleranceEstSq = 2e-3f; + //========================================= #ConfettiAnimationMathExtensionsEnd ======================================= //========================================= #ConfettiMathExtensionsEnd ================================================ @@ -416,6 +419,24 @@ inline const Vector3 select(const Vector3 & vec0, const Vector3 & vec1, bool sel // inline const Vector3 select(const Vector3 & vec0, const Vector3 & vec1, const BoolInVec & select1); +// Returns per element binary logical xor operation of _a and _b. +// _v[0...127] = _a[0...127] ^ _b[0...127] +// +inline const Vector3 xorPerElem(const Vector3& a, const FloatInVec b); + +// Compute the squareroot of a 3-D vector per element +// +inline const Vector3 sqrtPerElem(const Vector3& vec); + +// Returns the per component estimated reciprocal square root of v, where +// approximation is improved with one more new Newton-Raphson step. +// +inline const Vector3 rSqrtEstNR(const Vector3& v); + +// Tests if the components x, y and z of _v forms a normalized vector. +// +inline bool isNormalizedEst(const Vector3& v); + // Store x, y, and z elements of 3-D vector in first three words of a quadword, preserving fourth word // inline void storeXYZ(const Vector3 & vec, __m128 * quad); @@ -730,6 +751,10 @@ inline const Vector4 rSqrtEst(const Vector4& v); // inline const Vector4 rSqrtEstNR(const Vector4& v); +// Computes the per element arccosine +// +inline const Vector4 aCos(const Vector4& arg); + //========================================= #ConfettiAnimationMathExtensionsEnd ======================================= //========================================= #ConfettiMathExtensionsEnd ================================================ @@ -1425,6 +1450,10 @@ VECTORMATH_ALIGNED_TYPE_PRE class Quat // static inline const Quat rotationZ(const FloatInVec & radians); + static inline const Quat fromVectors(const Vector3& from, const Vector3& to); + + static inline const Quat fromAxisCosAngle(const Vector3& axis, const FloatInVec& cos); + } VECTORMATH_ALIGNED_TYPE_POST; // Multiply a quaternion by a scalar @@ -2843,6 +2872,10 @@ inline Vector4Int Select(const Vector4Int _b, const Vector4Int _true, const Vect // _v[0...127] = _a[0...127] & _b[0...127] inline Vector4Int And(const Vector4Int _a, const Vector4Int _b); +// Returns per element binary and operation of _a and _b. +// _v[0...127] = _a[0...127] & _b[0...127] +inline Vector4Int And(const Vector4Int& a, const BoolInVec b); + // Returns per element binary or operation of _a and _b. // _v[0...127] = _a[0...127] | _b[0...127] inline Vector4Int Or(const Vector4Int _a, const Vector4Int _b); diff --git a/Common_3/ThirdParty/OpenSource/basis_universal/basisu.vcxproj b/Common_3/ThirdParty/OpenSource/basis_universal/basisu.vcxproj index 74618fcc1c..007c49a23f 100644 --- a/Common_3/ThirdParty/OpenSource/basis_universal/basisu.vcxproj +++ b/Common_3/ThirdParty/OpenSource/basis_universal/basisu.vcxproj @@ -207,20 +207,20 @@ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(SolutionDir)$(Configuration)\ @@ -241,20 +241,20 @@ $(SolutionDir)$(Configuration)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(SolutionDir)$(Configuration)\ - $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)$(Configuration)\ + $(ProjectDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ @@ -401,7 +401,6 @@ MaxSpeed true true - false NDEBUG;_MBCS;%(PreprocessorDefinitions) @@ -425,7 +424,6 @@ MaxSpeed true true - false NDEBUG;_MBCS;%(PreprocessorDefinitions) @@ -449,7 +447,6 @@ MaxSpeed true true - false NDEBUG;_MBCS;%(PreprocessorDefinitions) @@ -473,7 +470,6 @@ MaxSpeed true true - false NDEBUG;_MBCS;%(PreprocessorDefinitions) diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Debug/Parser.exe b/Common_3/ThirdParty/OpenSource/hlslparser/Debug/Parser.exe index 028160412f..9a8410b798 100644 Binary files a/Common_3/ThirdParty/OpenSource/hlslparser/Debug/Parser.exe and b/Common_3/ThirdParty/OpenSource/hlslparser/Debug/Parser.exe differ diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.cpp b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.cpp index 29a67e2922..9b67a8419a 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.cpp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.cpp @@ -177,11 +177,11 @@ const char* GetBaseTypeName(const HLSLBaseType& baseType) case HLSLBaseType_TextureCube: return "textureCube"; case HLSLBaseType_TextureCubeArray: return "textureCubeArray"; - case HLSLBaseType_RWTexture1D: return "RWTexture1D"; - case HLSLBaseType_RWTexture1DArray: return "RWTexture1DArray"; - case HLSLBaseType_RWTexture2D: return "RWTexture2D"; - case HLSLBaseType_RWTexture2DArray: return "RWTexture1DArray"; - case HLSLBaseType_RWTexture3D: return "RWTexture3D"; + case HLSLBaseType_RWTexture1D: return "image1D"; + case HLSLBaseType_RWTexture1DArray: return "image1DArray"; + case HLSLBaseType_RWTexture2D: return "image2D"; + case HLSLBaseType_RWTexture2DArray: return "image1DArray"; + case HLSLBaseType_RWTexture3D: return "image3D"; case HLSLBaseType_Sampler: return "sampler"; case HLSLBaseType_Sampler2D: return "sampler2D"; @@ -389,7 +389,7 @@ const char* GetBaseTypeConstructor(const HLSLBaseType& baseType) } } -int GetObjectArraySize(HLSLType& type) +int TypeArraySize(HLSLType& type) { int size = 1; if (type.array) @@ -401,13 +401,13 @@ int GetObjectArraySize(HLSLType& type) return size; } -void GLSLGenerator::ProcessRegisterAssignments() +void AssignRegisters(HLSLRoot* root, const eastl::vector& shiftVec) { struct Range{int start, end;}; eastl::hash_map> spaces; // Gather allocated registers ranges - HLSLStatement* statement = m_tree->GetRoot()->statement; + HLSLStatement* statement = root->statement; while (statement != NULL) { switch(statement->nodeType) @@ -426,19 +426,19 @@ void GLSLGenerator::ProcessRegisterAssignments() if (regId >=0) { auto it = eastl::find( - m_options.shiftVec.begin(), - m_options.shiftVec.end(), + shiftVec.begin(), + shiftVec.end(), BindingShift{regType, spaceId}, [](const BindingShift& shift, const BindingShift& desc){ return shift.m_reg ==desc.m_reg && shift.m_space==desc.m_space; }); - if (it != m_options.shiftVec.end()) + if (it != shiftVec.end()) { regId += it->m_shift; pDeclaration->registerIndex += it->m_shift; } r.start = regId; - r.end = r.start + (GetObjectArraySize(pDeclaration->type) - 1); + r.end = r.start + (TypeArraySize(pDeclaration->type) - 1); spaces[spaceId].push_back(r); } break; @@ -501,7 +501,7 @@ void GLSLGenerator::ProcessRegisterAssignments() } // Assign registers - statement = m_tree->GetRoot()->statement; + statement = root->statement; while (statement != NULL) { switch(statement->nodeType) @@ -526,11 +526,10 @@ void GLSLGenerator::ProcessRegisterAssignments() auto& ranges = spaces[spaceId]; if (ranges.empty()) ranges.push_back({0, INT32_MAX}); - int size = GetObjectArraySize(pDeclaration->type); + int size = TypeArraySize(pDeclaration->type); auto it = eastl::find(ranges.begin(), ranges.end(), size, [](const Range& r, int sz){return r.end-r.start>=sz-1;}); if (it == ranges.end()) break; - pDeclaration->registerName = m_tree->AddStringFormatCached("x%d", it->start); pDeclaration->registerIndex = it->start; if (it->end - it->start + 1 <= size) ranges.erase(it); @@ -578,7 +577,6 @@ static bool GetCanImplicitCast(const HLSLType& srcType, const HLSLType& dstType) else tempDstType = dstType.baseType; - return tempSrcType == tempDstType; } @@ -1345,8 +1343,8 @@ static void WriteOpenglMatrixMultiplyVariation(CodeWriter & writer, tempLhs.baseType = lhsScalarType; HLSLType tempRhs; tempRhs.baseType = rhsScalarType; - HLSLType tempDst; - bool convertOk = HLSLParser::GetBinaryOpResultType(HLSLBinaryOp_Mul, tempLhs, tempRhs, tempDst); + HLSLType tempDst, argType; + bool convertOk = HLSLParser::GetBinaryOpResultType(HLSLBinaryOp_Mul, tempLhs, tempRhs, argType, tempDst); ASSERT_PARSER(convertOk); dstScalarType = tempDst.baseType; @@ -1569,7 +1567,7 @@ bool GLSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targ bool needs_asuint = m_tree->NeedsFunction(MakeCached("asuint")); bool needs_asint = m_tree->NeedsFunction(MakeCached("asint")); - ProcessRegisterAssignments(); + AssignRegisters(m_tree->GetRoot(), m_options.shiftVec); ChooseUniqueName("matrix_row", m_matrixRowFunction); ChooseUniqueName("matrix_ctor", m_matrixCtorFunction); @@ -2138,35 +2136,16 @@ const char* GLSLGenerator::GetResult() const return m_writer.GetResult(); } -void GLSLGenerator::OutputExpressionList(const eastl::vector& expressionVec, const eastl::vector& argumentVec, size_t start) +void GLSLGenerator::OutputExpressionList(const eastl::vector& expressionVec, size_t start) { for (size_t i = start; i < expressionVec.size(); i++) { - HLSLExpression* expression = expressionVec[i]; - HLSLArgument* argument = NULL; - if (i < argumentVec.size()) - { - argument = argumentVec[i]; - } - - HLSLType* expectedType = NULL; - if (argument != NULL) - { - //handle preprocessor - if (argument->type.baseType == HLSLBaseType_Unknown) - { - continue; - } - - expectedType = &argument->type; - } - if (i > start) { m_writer.Write(", "); } - OutputExpression(expression, expectedType); + OutputExpression(expressionVec[i]); } } @@ -2240,7 +2219,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* else if (expression->nodeType == HLSLNodeType_IdentifierExpression) { HLSLIdentifierExpression* identifierExpression = static_cast(expression); - OutputIdentifier(identifierExpression->pDeclaration->name); + OutputIdentifierExpression(identifierExpression); if (expression->functionExpression) { @@ -2257,7 +2236,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* else if (expression->nodeType == HLSLNodeType_CastingExpression) { HLSLCastingExpression* castingExpression = static_cast(expression); - OutputCast(castingExpression->type); + OutputCast(castingExpression->expressionType); m_writer.Write("("); OutputExpression(castingExpression->expression); m_writer.Write(")"); @@ -2435,7 +2414,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Min16Float: case HLSLBaseType_Min10Float: m_writer.Write("%s(", elementName.c_str()); - OutputExpression(binaryExpression->expression2, &binaryExpression->expression2->expressionType); + OutputExpression(binaryExpression->expression2); m_writer.Write(", 0.0, 0.0, 0.0)"); break; case HLSLBaseType_Float2: @@ -2443,7 +2422,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Min16Float2: case HLSLBaseType_Min10Float2: m_writer.Write("%s(", elementName.c_str()); - OutputExpression(binaryExpression->expression2, &binaryExpression->expression2->expressionType); + OutputExpression(binaryExpression->expression2); m_writer.Write(", 0.0, 0.0)"); break; case HLSLBaseType_Float3: @@ -2451,7 +2430,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Min16Float3: case HLSLBaseType_Min10Float3: m_writer.Write("%s(",elementName.c_str()); - OutputExpression(binaryExpression->expression2, &binaryExpression->expression2->expressionType); + OutputExpression(binaryExpression->expression2); m_writer.Write(", 0.0)"); break; case HLSLBaseType_Float4: @@ -2459,12 +2438,12 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Min16Float4: case HLSLBaseType_Min10Float4: m_writer.Write("%s(", elementName.c_str()); - OutputExpression(binaryExpression->expression2, &binaryExpression->expression2->expressionType); + OutputExpression(binaryExpression->expression2); m_writer.Write(")"); break; default: m_writer.Write("%s(", elementName.c_str()); - OutputExpression(binaryExpression->expression2, &binaryExpression->expression2->expressionType); + OutputExpression(binaryExpression->expression2); m_writer.Write(")"); break; } @@ -2968,7 +2947,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* const eastl::vector & args = functionCall->function->args; // Handle intrinsic funtions that are different between HLSL and GLSL. - bool handled = false; CachedString functionName = functionCall->function->name; if (String_Equal(functionName, "mul")) { @@ -2985,18 +2963,18 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* eastl::string matrixFunc = FetchCstr(m_stringLibrary, m_mulMatFunction); m_writer.Write("%s(", CHECK_CSTR(matrixFunc.c_str())); - OutputExpression(params[0], &type0); + OutputExpression(params[0]); m_writer.Write(","); - OutputExpression(params[1], &type1); + OutputExpression(params[1]); m_writer.Write(")"); } else { // standard multiply m_writer.Write("("); - OutputExpression(params[0], &type0); + OutputExpression(params[0]); m_writer.Write(")*("); - OutputExpression(params[1], &type1); + OutputExpression(params[1]); m_writer.Write(")"); } // These functions don't work any more because they rely on other code that has been removed. @@ -3026,8 +3004,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("))"); } #endif - - handled = true; } else if (String_Equal(functionName, "saturate")) { @@ -3036,7 +3012,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("clamp("); OutputExpression(params[0]); m_writer.Write(", 0.0, 1.0)"); - handled = true; } else if (String_Equal(functionName, "rcp")) { @@ -3044,7 +3019,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("1 / "); OutputExpression(params[0]); - handled = true; } else if (String_Equal(functionName, "rsqrt")) { @@ -3053,7 +3027,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("inversesqrt("); OutputExpression(params[0]); m_writer.Write(")"); - handled = true; } else if (String_Equal(functionName, "any") || String_Equal(functionName, "all")) { @@ -3084,8 +3057,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write(")"); m_writer.Write(")"); } - - handled = true; } else if (String_Equal(functionName, "pow")) { @@ -3108,27 +3079,22 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* } m_writer.Write(")"); - - handled = true; } else if (String_Equal(functionName, "WaveGetLaneIndex")) { m_writer.Write("gl_SubgroupInvocationID"); - - handled = true; } else if (String_Equal(functionName, "WaveGetLaneCount")) { m_writer.Write("gl_SubgroupSize"); - - handled = true; } else if (String_Equal(functionName, "Sample") || String_Equal(functionName, "SampleLevel") || String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero") || String_Equal(functionName, "SampleBias") || String_Equal(functionName, "GatherRed") || String_Equal(functionName, "SampleGrad")) { ASSERT_PARSER(params.size() >= 3); - if(String_Equal(functionName, "Sample")) + bool compareFunc = String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero"); + if (String_Equal(functionName, "Sample") || compareFunc) { m_writer.Write("texture("); } @@ -3149,14 +3115,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* ASSERT_PARSER(0); } } - else if (String_Equal(functionName, "SampleCmp")) - { - m_writer.Write("texture("); - } - else if (String_Equal(functionName, "SampleCmpLevelZero")) - { - m_writer.Write("texture("); - } else if (String_Equal(functionName, "SampleBias")) { m_writer.Write("textureOffset("); @@ -3170,70 +3128,57 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("textureGrad("); } - const char* arguementType = NULL; + HLSLBaseType textureType = params[0]->expressionType.baseType; - switch (params[0]->expressionType.baseType) + switch (textureType) { case HLSLBaseType_Texture1D: m_writer.Write("sampler1D"); - arguementType = "float"; break; case HLSLBaseType_Texture1DArray: m_writer.Write("sampler1DArray"); - arguementType = "vec2"; break; case HLSLBaseType_Texture2D: if (String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero")) { m_writer.Write("sampler2DShadow"); - arguementType = "vec4"; } else { m_writer.Write("sampler2D"); - arguementType = "vec2"; } - break; case HLSLBaseType_Texture2DArray: if (String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero")) { m_writer.Write("sampler2DArrayShadow"); - arguementType = "vec4"; } else { m_writer.Write("sampler2DArray"); - arguementType = "vec3"; - } + } break; case HLSLBaseType_Texture3D: m_writer.Write("sampler3D"); - arguementType = "vec3"; break; case HLSLBaseType_Texture2DMS: m_writer.Write("sampler2DMS"); - arguementType = "vec2"; break; case HLSLBaseType_Texture2DMSArray: m_writer.Write("sampler2DMSArray"); - arguementType = "vec3"; break; case HLSLBaseType_TextureCube: m_writer.Write("samplerCube"); - arguementType = "vec3"; break; case HLSLBaseType_TextureCubeArray: if (String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero")) { m_writer.Write("samplerCubeArrayShadow"); - arguementType = "vec4"; } else { m_writer.Write("samplerCubeArray"); - arguementType = "vec4"; - } + } break; default: break; @@ -3243,44 +3188,41 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* OutputExpression(params[0]); m_writer.Write(", "); OutputExpression(params[1]); - m_writer.Write(")"); + m_writer.Write("), "); - if (String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero")) + size_t start = 2; + if (compareFunc && textureType != HLSLBaseType_TextureCubeArray) { - - } - else - { - - } - - //while (expression != NULL) - for (int i = 2; i < params.size(); i++) - { - m_writer.Write(", "); - HLSLType* expectedType = &args[i]->type; - - if (i == 2) + start = 4; + switch (params[0]->expressionType.baseType) { - m_writer.Write("%s(", CHECK_CSTR(arguementType)); + case HLSLBaseType_Texture1D: + m_writer.Write("vec3("); + break; + case HLSLBaseType_Texture1DArray: + m_writer.Write("vec3("); + break; + case HLSLBaseType_Texture2D: + m_writer.Write("vec3("); + break; + case HLSLBaseType_Texture2DArray: + m_writer.Write("vec4("); + break; + case HLSLBaseType_TextureCube: + m_writer.Write("vec4("); + break; + default: + ASSERT_PARSER(false); } + OutputExpression(params[2]); + m_writer.Write(textureType==HLSLBaseType_Texture1D ? "0, " :", "); + OutputExpression(params[3]); + m_writer.Write(")"); + } - OutputExpression(params[i], expectedType); + OutputExpressionList(params, start); - if (String_Equal(functionName, "SampleCmp") || String_Equal(functionName, "SampleCmpLevelZero")) - { - if (i == 3) - m_writer.Write(")"); - } - else - { - if (i == 2) - m_writer.Write(")"); - } - } m_writer.Write(")"); - - handled = true; } else if (String_Equal(functionName, "GetDimensions")) { @@ -3301,74 +3243,18 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* OutputExpression(params[i], expectedType, false); } m_writer.Write(")"); -#if 0 - for (int i = 0; i < expressionVec.size(); i++) - { - if (i > 0) - { - m_writer.Write(";\n"); - m_writer.Write(1, ""); - } - - HLSLExpression * exp = expressionVec[i]; - OutputExpression(exp, expectedType, false); - - m_writer.Write(" = textureSize("); - - const HLSLTextureStateExpression* pTextureStateExpression = functionCall->pTextureStateExpression; - - m_writer.Write("%s", FetchCstr(m_stringLibrary, pTextureStateExpression->name)); - - if (pTextureStateExpression->bArray) - { - for (int i = 0; i < (int)pTextureStateExpression->arrayDimension; i++) - { - if (pTextureStateExpression->arrayExpression) - { - m_writer.Write("["); - OutputExpressionList(pTextureStateExpression->arrayExpression); - m_writer.Write("]"); - } - else if (pTextureStateExpression->arrayIndex[i] > 0) - m_writer.Write("[%u]", pTextureStateExpression->arrayIndex[i]); - else - m_writer.Write("[]"); - } - } - - // This is a temporary solution. In glsl, the lod is required, and we don't have the - // variations, as well as the equivelent of textureQueryLevels. So we technically need - // to figure out which overload we are using, and then call the correct combinations of - // textureSize() and textureQueryLevels(). But as a temporary solution, just hardcode the - // mip level to 0. - - if(i == 0) - m_writer.Write(",0).x"); - else if (i == 1) - m_writer.Write(",0).y"); - else if (i == 2) - m_writer.Write(",0).z"); - else if (i == 3) - m_writer.Write(",0).w"); - } -#endif - } else { // TODO: error or unhandled ASSERT_PARSER(0); } - - handled = true; } /// !!! need to check it later else if (String_Equal(functionName, "Load")) { ASSERT_PARSER(params.size()>=2); - HLSLType* expectedType = &args[1]->type; - if (IsTexture(params[0]->expressionType.baseType)) { m_writer.Write("texelFetch("); @@ -3383,29 +3269,29 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Texture1D: m_writer.Write("("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").x, "); m_writer.Write("("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").y"); break; case HLSLBaseType_Texture1DArray: m_writer.Write("ivec2("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").xy, "); m_writer.Write("("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").z"); break; case HLSLBaseType_Texture2D: m_writer.Write("ivec2("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").xy"); //offset @@ -3419,7 +3305,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").z"); break; @@ -3457,11 +3343,11 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Texture2DArray: m_writer.Write("ivec3("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").xyz, "); m_writer.Write("("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").w"); break; @@ -3487,7 +3373,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* case HLSLBaseType_Texture3D: m_writer.Write("ivec3("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").xyz"); //offset @@ -3501,7 +3387,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write(", "); m_writer.Write("("); - OutputExpression(params[1], expectedType); + OutputExpression(params[1]); m_writer.Write(").w"); break; default: @@ -3518,8 +3404,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* OutputExpression(params[1]); m_writer.Write("]"); } - - handled = true; } else if (String_Equal(functionName, "Store")) { @@ -3530,8 +3414,6 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("]"); m_writer.Write(" = "); OutputExpression(params[2]); - - handled = true; } else if (String_Equal(functionName, "InterlockedAdd") || String_Equal(functionName, "InterlockedAnd") || @@ -3553,14 +3435,14 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* ASSERT_PARSER(argumentVec.size() == 3); HLSLType* expectedType = NULL; - + { expectedType = &argumentVec[2]->type; } bool isImage = IsTextureType(params[0]->expressionType.baseType); - OutputExpression(params[2], expectedType); + OutputExpression(params[2]); m_writer.Write(" = "); @@ -3606,12 +3488,7 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* { m_writer.Write(", "); - HLSLType* expectedType = NULL; - if (iter < argumentVec.size()) - { - expectedType = &argumentVec[iter]->type; - } - OutputExpression(params[iter], expectedType); + OutputExpression(params[iter]); } m_writer.Write(")"); @@ -3656,14 +3533,11 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* numExpressions2++; } #endif - - handled = true; } } - - if (!handled) - { + else + { if (String_Equal(functionName, "asfloat")) { int temp = 0; @@ -3671,35 +3545,20 @@ void GLSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* } OutputIdentifier(functionName); - m_writer.Write("("); - OutputExpressionList(functionCall->params, functionCall->function->args); - m_writer.Write(")"); - } - } - else - { - m_writer.Write(""); - } + m_writer.Write("("); + OutputExpressionList(functionCall->params); + m_writer.Write(")"); + } + } + else + { + m_writer.Write(""); + } if (cast) { -/* - const BaseTypeDescription& srcTypeDesc = _baseTypeDescriptions[expression->expressionType.baseType]; - const BaseTypeDescription& dstTypeDesc = _baseTypeDescriptions[dstType->baseType]; - - if (dstTypeDesc.numDimensions == 1 && dstTypeDesc.numComponents > 1) - { - // Casting to a vector - pad with 0s - for (int i = srcTypeDesc.numComponents; i < dstTypeDesc.numComponents; ++i) - { - m_writer.Write(", 0"); - } - } -*/ - m_writer.Write(")"); } - } void GLSLGenerator::OutputIdentifier(const CachedString & srcName) @@ -3994,50 +3853,45 @@ void GLSLGenerator::OutputIdentifier(const CachedString & srcName) { dstName = srcName; - // if it is one of StructuredBuffer's Name - for (int index = 0; index < m_StructuredBufferNames.size(); index++) - { - if (String_Equal(m_StructuredBufferNames[index], dstName)) - { - HLSLBuffer *buffer = m_tree->FindBuffer(dstName); + // The identifier could be a GLSL reserved word (if it's not also a HLSL reserved word). + CachedString baseName = dstName; + dstName = GetSafeIdentifierName(baseName); + } + m_writer.Write("%s", FetchCstr(m_stringLibrary, dstName)); +} - if (buffer->type.array && buffer->type.arrayDimension > 0) - { - // original code for reference, we have an extra name in there, but I think it's harmless. Fixing it anyways. - // m_writer.Write("%s", name, name); - m_writer.Write("%s", FetchCstr(m_stringLibrary, dstName)); - } - else - m_writer.Write("%s_Data", FetchCstr(m_stringLibrary, dstName)); - return; - } - } +void GLSLGenerator::OutputIdentifierExpression(HLSLIdentifierExpression* pIdentExpr) +{ + CachedString baseName = pIdentExpr->pDeclaration->name; - // if it is one of PushConstaantBuffer's data's Name - for (int index = 0; index < m_PushConstantBuffers.size(); index++) - { - HLSLBuffer* buffer = static_cast(m_PushConstantBuffers[index]); - HLSLDeclaration* field = buffer->field; + if (IsBuffer(pIdentExpr->expressionType.baseType)) + { + HLSLBuffer *buffer = static_cast(pIdentExpr->pDeclaration); - while (field != NULL) - { - if (!field->hidden) - { - if (String_Equal(field->name, dstName)) - { - m_writer.Write("%s.%s", FetchCstr(m_stringLibrary, buffer->name), FetchCstr(m_stringLibrary, dstName)); - return; - } - } - field = (HLSLDeclaration*)field->nextStatement; - } + if (buffer->type.array && buffer->type.arrayDimension > 0) + { + // original code for reference, we have an extra name in there, but I think it's harmless. Fixing it anyways. + // m_writer.Write("%s", name, name); + m_writer.Write("%s", FetchCstr(m_stringLibrary, baseName)); } + else + m_writer.Write("%s_Data", FetchCstr(m_stringLibrary, baseName)); + return; + } - // The identifier could be a GLSL reserved word (if it's not also a HLSL reserved word). - CachedString baseName = dstName; - dstName = GetSafeIdentifierName(baseName); + // if it is one of PushConstaantBuffer's data's Name + if (pIdentExpr->pDeclaration->buffer) + { + HLSLBuffer* buffer = static_cast(pIdentExpr->pDeclaration->buffer); + if (buffer->bPushConstant) + m_writer.Write("%s.%s", FetchCstr(m_stringLibrary, buffer->name), FetchCstr(m_stringLibrary, baseName)); + else + m_writer.Write("%s", FetchCstr(m_stringLibrary, baseName)); + return; } - m_writer.Write("%s", FetchCstr(m_stringLibrary, dstName)); + + // The identifier could be a GLSL reserved word (if it's not also a HLSL reserved word). + m_writer.Write("%s", FetchCstr(m_stringLibrary, GetSafeIdentifierName(baseName))); } void GLSLGenerator::OutputArguments(const eastl::vector& arguments) @@ -4254,179 +4108,86 @@ void GLSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const { HLSLTextureState* textureState = static_cast(statement); - if (IsTexture(textureState->type.baseType)) + const char* prefix = ""; + switch (GetScalarBaseType(textureState->type.elementType)) { - m_writer.BeginLine(indent, RawStr(textureState->fileName), textureState->line); - - m_writer.Write("layout(set = %d, binding = %d) uniform ", textureState->registerSpace, textureState->registerIndex); - - HLSLBaseType scalarType = GetScalarBaseType(textureState->type.elementType); - eastl::string prefix = ""; - if (scalarType == HLSLBaseType_Int) - { - prefix = "i"; - } - else if (scalarType == HLSLBaseType_Uint) - { - prefix = "u"; - } - - switch (textureState->type.baseType) - { - case HLSLBaseType_Texture1D: - m_writer.Write("%stexture1D", prefix.c_str()); - break; - case HLSLBaseType_Texture1DArray: - m_writer.Write("%stexture1DArray", prefix.c_str()); - break; - case HLSLBaseType_Texture2D: - m_writer.Write("%stexture2D", prefix.c_str()); - break; - case HLSLBaseType_Texture2DArray: - m_writer.Write("%stexture2DArray", prefix.c_str()); - break; - case HLSLBaseType_Texture3D: - m_writer.Write("%stexture3D", prefix.c_str()); - break; - case HLSLBaseType_Texture2DMS: - m_writer.Write("%stexture2DMS", prefix.c_str()); - break; - case HLSLBaseType_Texture2DMSArray: - m_writer.Write("%stexture2DMSArray", prefix.c_str()); - break; - case HLSLBaseType_TextureCube: - m_writer.Write("%stextureCube", prefix.c_str()); - break; - case HLSLBaseType_TextureCubeArray: - m_writer.Write("%stextureCubeArray", prefix.c_str()); - break; - default: - break; - } - - m_writer.Write(" %s", RawStr(textureState->name)); - - if (textureState->type.array) - { - OutputArrayExpression(textureState->type.arrayDimension, textureState->arrayDimExpression); - } - - m_writer.EndLine(";"); + case HLSLBaseType_Int: prefix = "i";break; + case HLSLBaseType_Uint: prefix = "u";break; } - else if (IsRWTexture(textureState->type.baseType) || IsRasterizerOrderedTexture(textureState->type.baseType)) - { - m_writer.BeginLine(indent, RawStr(textureState->fileName), textureState->line); - m_writer.Write("layout(set = %d, binding = %d", textureState->registerSpace, textureState->registerIndex); - - bool bUint = false; + const char* baseTypeName = GetBaseTypeName(textureState->type.baseType); + const char* elementType = ""; + m_writer.BeginLine(indent, RawStr(textureState->fileName), textureState->line); + if (IsRWTexture(textureState->type.baseType) || IsRasterizerOrderedTexture(textureState->type.baseType)) + { // note: we are promoting 3 float types to 4 switch (textureState->type.elementType) { case HLSLBaseType_Float: - m_writer.Write(", r32f"); + elementType = ", r32f"; break; case HLSLBaseType_Float2: - m_writer.Write(", rg32f"); + elementType = ", rg32f"; break; case HLSLBaseType_Float3: case HLSLBaseType_Float4: - m_writer.Write(", rgba32f"); + elementType = ", rgba32f"; break; case HLSLBaseType_Half: case HLSLBaseType_Min16Float: - m_writer.Write(", r16f"); + elementType = ", r16f"; break; case HLSLBaseType_Half2: case HLSLBaseType_Min16Float2: - m_writer.Write(", rg16f"); + elementType = ", rg16f"; break; case HLSLBaseType_Half3: case HLSLBaseType_Min16Float3: case HLSLBaseType_Half4: case HLSLBaseType_Min16Float4: - m_writer.Write(", rgba16f"); + elementType = ", rgba16f"; break; case HLSLBaseType_Int: - m_writer.Write(", r32i"); + elementType = ", r32i"; break; case HLSLBaseType_Int2: - m_writer.Write(", rg32i"); + elementType = ", rg32i"; break; case HLSLBaseType_Int3: case HLSLBaseType_Int4: - m_writer.Write(", rgba32i"); + elementType = ", rgba32i"; break; case HLSLBaseType_Uint: - m_writer.Write(", r32ui"); bUint = true; + elementType = ", r32ui"; break; case HLSLBaseType_Uint2: - m_writer.Write(", rg32ui"); bUint = true; + elementType = ", rg32ui"; break; case HLSLBaseType_Uint3: case HLSLBaseType_Uint4: - m_writer.Write(", rgba32ui"); bUint = true; + elementType = ", rgba32ui"; break; default: Error("Unknown RWTexture type %d", (int)textureState->type.elementType); break; } + } - m_writer.Write(") uniform "); - - - switch (textureState->type.baseType) - { - case HLSLBaseType_RWTexture1D: - - if (bUint) - m_writer.Write("uimage1D"); - else - m_writer.Write("image1D"); - break; - case HLSLBaseType_RWTexture1DArray: - if (bUint) - m_writer.Write("uimage1DArray"); - else - m_writer.Write("image1DArray"); - break; - case HLSLBaseType_RWTexture2D: - if (bUint) - m_writer.Write("uimage2D"); - else - m_writer.Write("image2D"); - break; - case HLSLBaseType_RWTexture2DArray: - if (bUint) - m_writer.Write("uimage2DArray"); - else - m_writer.Write("image2DArray"); - break; - case HLSLBaseType_RWTexture3D: - if (bUint) - m_writer.Write("uimage3D"); - else - m_writer.Write("image3D"); - break; - default: - break; - } - - m_writer.Write(" %s", RawStr(textureState->name)); + m_writer.Write("layout(set = %d, binding = %d%s) uniform %s%s %s", + textureState->registerSpace, textureState->registerIndex, elementType, + prefix, baseTypeName, RawStr(textureState->name)); - if (textureState->type.array) - { - OutputArrayExpression(textureState->type.arrayDimension, textureState->arrayDimExpression); - } - - m_writer.EndLine(";"); + if (textureState->type.array) + { + OutputArrayExpression(textureState->type.arrayDimension, textureState->arrayDimExpression); } - - } + + m_writer.EndLine(";"); + } else if (statement->nodeType == HLSLNodeType_GroupShared) { HLSLGroupShared* pGroupShared = static_cast(statement); @@ -5466,7 +5227,7 @@ void GLSLGenerator::OutputAttribute(const HLSLType& type, const CachedString & s { m_writer.Write("layout(location = %d) ", *counter); - *counter += GetObjectArraySize(field->type); + *counter += TypeArraySize(field->type); if( (m_target == Target_HullShader && modifier == AttributeModifier_Out) || (m_target == Target_DomainShader && modifier == AttributeModifier_In)) m_writer.Write("patch %s ", FetchCstr(m_stringLibrary, qualifier)); diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.h b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.h index 6283c58237..cd5bf1308c 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.h +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/GLSLGenerator.h @@ -75,11 +75,12 @@ class GLSLGenerator AttributeModifier_Inout, }; - void OutputExpressionList(const eastl::vector& expressions, const eastl::vector & argument = {}, size_t i = 0); + void OutputExpressionList(const eastl::vector& expressions, size_t i = 0); void OutputExpression(HLSLExpression* expression, const HLSLType* dstType = NULL, bool allowCast = true); void OutputExpressionForBufferArray(HLSLExpression* expression, const HLSLType* dstType = NULL); - void OutputIdentifier(const CachedString & name); + void OutputIdentifier(const CachedString & name); + void OutputIdentifierExpression(HLSLIdentifierExpression* pIdentExpr); void OutputArguments(const eastl::vector < HLSLArgument* > & arguments); @@ -133,10 +134,7 @@ class GLSLGenerator CachedString MakeCached(const char * str); - void ProcessRegisterAssignments(); - private: - static const int s_numReservedWords = 7; static const char* s_reservedWord[s_numReservedWords]; diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLGenerator.cpp b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLGenerator.cpp index 29e0cae7d9..7b19d439ee 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLGenerator.cpp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLGenerator.cpp @@ -674,7 +674,7 @@ void HLSLGenerator::OutputExpression(HLSLExpression* expression, bool needsEndPa { HLSLCastingExpression* castingExpression = static_cast(expression); m_writer.Write("("); - OutputDeclaration(castingExpression->type, MakeCached("")); + OutputDeclaration(castingExpression->expressionType, MakeCached("")); m_writer.Write(")"); m_writer.Write("("); OutputExpression(castingExpression->expression, false); @@ -1490,7 +1490,7 @@ void HLSLGenerator::OutputStatements(int indent, HLSLStatement* statement) m_writer.BeginLine(indent, RawStr(ifStatement->fileName), ifStatement->line); m_writer.Write("if ("); - OutputExpression(ifStatement->condition, true); + OutputExpression(ifStatement->condition, false); m_writer.Write(")"); m_writer.EndLine(); diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.cpp b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.cpp index ad0a1ddf44..68b3700560 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.cpp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.cpp @@ -149,23 +149,6 @@ static HLSLParser::Intrinsic * MakeIntrinsicInOut(StringLibrary & stringLibrary, } */ - - -enum NumericType -{ - NumericType_Float, - NumericType_Half, - NumericType_Min16Float, - NumericType_Min10Float, - NumericType_Bool, - NumericType_Int, - NumericType_Uint, - NumericType_Count, - NumericType_NaN, -}; - - - // note: going from float to int is more expensive than from int to float, so that things like: // max(float,int) -> max(float,float) instead of mac(int,int) static const int _numberTypeRank[NumericType_Count][NumericType_Count] = @@ -445,17 +428,6 @@ static const EffectState pipelineStates[] = { {"AlphaTest", 0, booleanValues}, // This is really alpha to coverage. }; - -struct BaseTypeDescription -{ - const char* typeName; - NumericType numericType; - int numComponents; - int numDimensions; - int height; - int binaryOpRank; -}; - #define INTRINSIC_VOID_FUNCTION_CACHED(name) \ m_intrinsics.push_back(new Intrinsic( m_intrinsicStringLibrary, name, HLSLBaseType_Void )); @@ -3041,175 +3013,6 @@ const int _binaryOpPriority[] = 9 // % }; -const BaseTypeDescription _baseTypeDescriptions[HLSLBaseType_Count] = - { - { "unknown type", NumericType_NaN, 0, 0, 0, -1 }, // HLSLBaseType_Unknown - { "void", NumericType_NaN, 0, 0, 0, -1 }, // HLSLBaseType_Void - - { "float", NumericType_Float, 1, 0, 1, 0 }, // HLSLBaseType_Float - { "float1x2", NumericType_Float, 1, 2, 2, 0 }, // HLSLBaseType_Float1x2 - { "float1x3", NumericType_Float, 1, 2, 3, 0 }, // HLSLBaseType_Float1x3 - { "float1x4", NumericType_Float, 1, 2, 4, 0 }, // HLSLBaseType_Float1x4 - { "float2", NumericType_Float, 2, 1, 1, 0 }, // HLSLBaseType_Float2 - { "float2x2", NumericType_Float, 2, 2, 2, 0 }, // HLSLBaseType_Float2x2 - { "float2x3", NumericType_Float, 2, 2, 3, 0 }, // HLSLBaseType_Float2x3 - { "float2x4", NumericType_Float, 2, 2, 4, 0 }, // HLSLBaseType_Float2x4 - { "float3", NumericType_Float, 3, 1, 1, 0 }, // HLSLBaseType_Float3 - { "float3x2", NumericType_Float, 3, 2, 2, 0 }, // HLSLBaseType_Float3x2 - { "float3x3", NumericType_Float, 3, 2, 3, 0 }, // HLSLBaseType_Float3x3 - { "float3x4", NumericType_Float, 3, 2, 4, 0 }, // HLSLBaseType_Float3x4 - { "float4", NumericType_Float, 4, 1, 1, 0 }, // HLSLBaseType_Float4 - { "float4x2", NumericType_Float, 4, 2, 2, 0 }, // HLSLBaseType_Float4x2 - { "float4x3", NumericType_Float, 4, 2, 3, 0 }, // HLSLBaseType_Float4x3 - { "float4x4", NumericType_Float, 4, 2, 4, 0 }, // HLSLBaseType_Float4x4 - - - { "half", NumericType_Half, 1, 0, 1, 1 }, // HLSLBaseType_Half - { "half1x2", NumericType_Half, 1, 2, 2, 1 }, // HLSLBaseType_Half1x2 - { "half1x3", NumericType_Half, 1, 2, 3, 1 }, // HLSLBaseType_Half1x3 - { "half1x4", NumericType_Half, 1, 2, 4, 1 }, // HLSLBaseType_Half1x4 - { "half2", NumericType_Half, 2, 1, 1, 1 }, // HLSLBaseType_Half2 - { "half2x2", NumericType_Half, 2, 2, 2, 1 }, // HLSLBaseType_Half2x2 - { "half2x3", NumericType_Half, 2, 2, 3, 1 }, // HLSLBaseType_Half2x3 - { "half2x4", NumericType_Half, 2, 2, 4, 1 }, // HLSLBaseType_Half2x4 - { "half3", NumericType_Half, 3, 1, 1, 1 }, // HLSLBaseType_Half3 - { "half3x2", NumericType_Half, 3, 2, 2, 1 }, // HLSLBaseType_Half3x2 - { "half3x3", NumericType_Half, 3, 2, 3, 1 }, // HLSLBaseType_Half3x3 - { "half3x4", NumericType_Half, 3, 2, 4, 1 }, // HLSLBaseType_Half3x4 - { "half4", NumericType_Half, 4, 1, 1, 1 }, // HLSLBaseType_Half4 - { "half4x2", NumericType_Half, 4, 2, 2, 1 }, // HLSLBaseType_Half4x2 - { "half4x3", NumericType_Half, 4, 2, 3, 1 }, // HLSLBaseType_Half4x3 - { "half4x4", NumericType_Half, 4, 2, 4, 1 }, // HLSLBaseType_Half4x4 - - - { "min16float", NumericType_Min16Float, 1, 0, 1, 1 }, // HLSLBaseType_Min16Float - { "min16float1x2", NumericType_Min16Float, 1, 2, 2, 1 }, // HLSLBaseType_Min16Float1x2 - { "min16float1x3", NumericType_Min16Float, 1, 2, 3, 1 }, // HLSLBaseType_Min16Float1x3 - { "min16float1x4", NumericType_Min16Float, 1, 2, 4, 1 }, // HLSLBaseType_Min16Float1x4 - { "min16float2", NumericType_Min16Float, 2, 1, 1, 1 }, // HLSLBaseType_Min16Float2 - { "min16float2x2", NumericType_Min16Float, 2, 2, 2, 1 }, // HLSLBaseType_Min16Float2x2 - { "min16float2x3", NumericType_Min16Float, 2, 2, 3, 1 }, // HLSLBaseType_Min16Float2x3 - { "min16float2x4", NumericType_Min16Float, 2, 2, 4, 1 }, // HLSLBaseType_Min16Float2x4 - { "min16float3", NumericType_Min16Float, 3, 1, 1, 1 }, // HLSLBaseType_Min16Float3 - { "min16float3x2", NumericType_Min16Float, 3, 2, 2, 1 }, // HLSLBaseType_Min16Float3x2 - { "min16float3x3", NumericType_Min16Float, 3, 2, 3, 1 }, // HLSLBaseType_Min16Float3x3 - { "min16float3x4", NumericType_Min16Float, 3, 2, 4, 1 }, // HLSLBaseType_Min16Float3x4 - { "min16float4", NumericType_Min16Float, 4, 1, 1, 1 }, // HLSLBaseType_Min16Float4 - { "min16float4x2", NumericType_Min16Float, 4, 2, 2, 1 }, // HLSLBaseType_Min16Float4x2 - { "min16float4x3", NumericType_Min16Float, 4, 2, 3, 1 }, // HLSLBaseType_Min16Float4x3 - { "min16float4x4", NumericType_Min16Float, 4, 2, 4, 1 }, // HLSLBaseType_Min16Float4x4 - - - { "min10float", NumericType_Min10Float, 1, 0, 1, 1 }, // HLSLBaseType_Min10Float - { "min10float1x2", NumericType_Min10Float, 1, 2, 2, 1 }, // HLSLBaseType_Min10Float1x2 - { "min10float1x3", NumericType_Min10Float, 1, 2, 3, 1 }, // HLSLBaseType_Min10Float1x3 - { "min10float1x4", NumericType_Min10Float, 1, 2, 4, 1 }, // HLSLBaseType_Min10Float1x4 - { "min10float2", NumericType_Min10Float, 2, 1, 1, 1 }, // HLSLBaseType_Min10Float2 - { "min10float2x2", NumericType_Min10Float, 2, 2, 2, 1 }, // HLSLBaseType_Min10Float2x2 - { "min10float2x3", NumericType_Min10Float, 2, 2, 3, 1 }, // HLSLBaseType_Min10Float2x3 - { "min10float2x4", NumericType_Min10Float, 2, 2, 4, 1 }, // HLSLBaseType_Min10Float2x4 - { "min10float3", NumericType_Min10Float, 3, 1, 1, 1 }, // HLSLBaseType_Min10Float3 - { "min10float3x2", NumericType_Min10Float, 3, 2, 2, 1 }, // HLSLBaseType_Min10Float3x2 - { "min10float3x3", NumericType_Min10Float, 3, 2, 3, 1 }, // HLSLBaseType_Min10Float3x3 - { "min10float3x4", NumericType_Min10Float, 3, 2, 4, 1 }, // HLSLBaseType_Min10Float3x4 - { "min10float4", NumericType_Min10Float, 4, 1, 1, 1 }, // HLSLBaseType_Min10Float4 - { "min10float4x2", NumericType_Min10Float, 4, 2, 2, 1 }, // HLSLBaseType_Min10Float4x2 - { "min10float4x3", NumericType_Min10Float, 4, 2, 3, 1 }, // HLSLBaseType_Min10Float4x3 - { "min10float4x4", NumericType_Min10Float, 4, 2, 4, 1 }, // HLSLBaseType_Min10Float4x4 - - { "bool", NumericType_Bool, 1, 0, 1, 4 }, // HLSLBaseType_Bool - { "bool1x2", NumericType_Bool, 1, 2, 2, 4 }, // HLSLBaseType_Bool1x2 - { "bool1x3", NumericType_Bool, 1, 2, 3, 4 }, // HLSLBaseType_Bool1x3 - { "bool1x4", NumericType_Bool, 1, 2, 4, 4 }, // HLSLBaseType_Bool1x4 - { "bool2", NumericType_Bool, 2, 1, 1, 4 }, // HLSLBaseType_Bool2 - { "bool2x2", NumericType_Bool, 2, 2, 2, 4 }, // HLSLBaseType_Bool1x2 - { "bool2x3", NumericType_Bool, 2, 2, 3, 4 }, // HLSLBaseType_Bool1x3 - { "bool2x4", NumericType_Bool, 2, 2, 4, 4 }, // HLSLBaseType_Bool1x4 - { "bool3", NumericType_Bool, 3, 1, 1, 4 }, // HLSLBaseType_Bool3 - { "bool3x2", NumericType_Bool, 3, 2, 2, 4 }, // HLSLBaseType_Bool1x2 - { "bool3x3", NumericType_Bool, 3, 2, 3, 4 }, // HLSLBaseType_Bool1x3 - { "bool3x4", NumericType_Bool, 3, 2, 4, 4 }, // HLSLBaseType_Bool1x4 - { "bool4", NumericType_Bool, 4, 1, 1, 4 }, // HLSLBaseType_Bool4 - { "bool4x2", NumericType_Bool, 4, 2, 2, 4 }, // HLSLBaseType_Bool1x2 - { "bool4x3", NumericType_Bool, 4, 2, 3, 4 }, // HLSLBaseType_Bool1x3 - { "bool4x4", NumericType_Bool, 4, 2, 4, 4 }, // HLSLBaseType_Bool1x4 - - { "int", NumericType_Int, 1, 0, 1, 3 }, // HLSLBaseType_Int - { "int1x2", NumericType_Int, 1, 2, 2, 3 }, // HLSLBaseType_Int1x2 - { "int1x3", NumericType_Int, 1, 2, 3, 3 }, // HLSLBaseType_Int1x3 - { "int1x4", NumericType_Int, 1, 2, 4, 3 }, // HLSLBaseType_Int1x4 - { "int2", NumericType_Int, 2, 1, 1, 3 }, // HLSLBaseType_Int2 - { "int2x2", NumericType_Int, 2, 2, 2, 3 }, // HLSLBaseType_Int2x2 - { "int2x3", NumericType_Int, 2, 2, 3, 3 }, // HLSLBaseType_Int2x3 - { "int2x4", NumericType_Int, 2, 2, 4, 3 }, // HLSLBaseType_Int2x4 - { "int3", NumericType_Int, 3, 1, 1, 3 }, // HLSLBaseType_Int3 - { "int3x2", NumericType_Int, 3, 2, 2, 3 }, // HLSLBaseType_Int3x2 - { "int3x3", NumericType_Int, 3, 2, 3, 3 }, // HLSLBaseType_Int3x3 - { "int3x4", NumericType_Int, 3, 2, 4, 3 }, // HLSLBaseType_Int3x4 - { "int4", NumericType_Int, 4, 1, 1, 3 }, // HLSLBaseType_Int4 - { "int4x2", NumericType_Int, 4, 2, 2, 3 }, // HLSLBaseType_Int4x2 - { "int4x3", NumericType_Int, 4, 2, 3, 3 }, // HLSLBaseType_Int4x3 - { "int4x4", NumericType_Int, 4, 2, 4, 3 }, // HLSLBaseType_Int4x4 - - { "uint", NumericType_Uint, 1, 0, 1, 2 }, // HLSLBaseType_Uint - { "uint1x2", NumericType_Uint, 1, 2, 2, 2 }, // HLSLBaseType_Int1x2 - { "uint1x3", NumericType_Uint, 1, 2, 3, 2 }, // HLSLBaseType_Int1x3 - { "uint1x4", NumericType_Uint, 1, 2, 4, 2 }, // HLSLBaseType_Int1x4 - { "uint2", NumericType_Uint, 2, 1, 1, 2 }, // HLSLBaseType_Uint2 - { "uint2x2", NumericType_Uint, 1, 2, 2, 2 }, // HLSLBaseType_Uint1x2 - { "uint2x3", NumericType_Uint, 1, 2, 3, 2 }, // HLSLBaseType_Uint1x3 - { "uint2x4", NumericType_Uint, 1, 2, 4, 2 }, // HLSLBaseType_Uint1x4 - { "uint3", NumericType_Uint, 3, 1, 1, 2 }, // HLSLBaseType_Uint3 - { "uint3x2", NumericType_Uint, 1, 2, 2, 2 }, // HLSLBaseType_Uint1x2 - { "uint3x3", NumericType_Uint, 1, 2, 3, 2 }, // HLSLBaseType_Uint1x3 - { "uint3x4", NumericType_Uint, 1, 2, 4, 2 }, // HLSLBaseType_Uint1x4 - { "uint4", NumericType_Uint, 4, 1, 1, 2 }, // HLSLBaseType_Uint4 - { "uint4x2", NumericType_Uint, 1, 2, 2, 2 }, // HLSLBaseType_Uint1x2 - { "uint4x3", NumericType_Uint, 1, 2, 3, 2 }, // HLSLBaseType_Uint1x3 - { "uint4x4", NumericType_Uint, 1, 2, 4, 2 }, // HLSLBaseType_Uint1x4 - - - { "inputPatch", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_InputPatch - { "outputPatch", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_OutputPatch - - { "pointStream", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_PointStream - { "lineStream", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_LineStream - { "triangleStream", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_TriangleStream - - { "point", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Point - { "line", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Line - { "triangle", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Triangle - { "lineadj", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Lineadj - { "triangleadj", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Triangleadj - - { "texture", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture - { "Texture1D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture1D - { "Texture1DArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture1DArray - { "Texture2D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture2D - { "Texture2DArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture2DArray - { "Texture3D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture3D - { "Texture2DMS", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture2DMS - { "Texture2DMSArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Texture2DMSArray - { "TextureCube", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_TextureCube - { "TextureCubeArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_TextureCubeArray - - { "RWTexture1D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_RWTexture1D - { "RWTexture1DArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_RWTexture1DArray - { "RWTexture2D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_RWTexture2D - { "RWTexture2DArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_RWTexture2DArray - { "RWTexture3D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_RWTexture3D - - - { "sampler", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Sampler - { "sampler2D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Sampler2D - { "sampler3D", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Sampler3D - { "samplerCUBE", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_SamplerCube - { "sampler2DShadow", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Sampler2DShadow - { "sampler2DMS", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Sampler2DMS - { "sampler2DArray", NumericType_NaN, 1, 0, 0, -1 }, // HLSLBaseType_Sampler2DArray - { "user defined", NumericType_NaN, 1, 0, 0, -1 } // HLSLBaseType_UserDefined - }; - // IC: I'm not sure this table is right, but any errors should be caught by the backend compiler. // Also, this is operator dependent. The type resulting from (float4 * float4x4) is not the same as (float4 + float4x4). // We should probably distinguish between component-wise operator and only allow same dimensions @@ -7301,12 +7104,12 @@ CachedString HLSLParser::GetTypeName(const HLSLType& type) } else { - return m_tree->AddStringCached(_baseTypeDescriptions[type.elementType].typeName); + return m_tree->AddStringCached(BASE_TYPE_DESC[type.elementType].typeName); } } else { - return m_tree->AddStringCached(_baseTypeDescriptions[type.baseType].typeName); + return m_tree->AddStringCached(BASE_TYPE_DESC[type.baseType].typeName); } } @@ -7389,8 +7192,8 @@ static int GetTypeCastRank(HLSLTree * tree, const HLSLType& srcType, const HLSLT return 0; } - const BaseTypeDescription& srcDesc = _baseTypeDescriptions[comparingType]; - const BaseTypeDescription& dstDesc = _baseTypeDescriptions[comparedType]; + const BaseTypeDescription& srcDesc = BASE_TYPE_DESC[comparingType]; + const BaseTypeDescription& dstDesc = BASE_TYPE_DESC[comparedType]; if (srcDesc.numericType == NumericType_NaN || dstDesc.numericType == NumericType_NaN) { return -1; @@ -7399,20 +7202,18 @@ static int GetTypeCastRank(HLSLTree * tree, const HLSLType& srcType, const HLSLT // Result bits: T R R R P (T = truncation, R = conversion rank, P = dimension promotion) int result = _numberTypeRank[srcDesc.numericType][dstDesc.numericType] << 1; - if (srcDesc.numDimensions == 0 && dstDesc.numDimensions > 0) + if ((srcDesc.numComponents == 1 && srcDesc.numRows == 1) && (dstDesc.numComponents > 1 || dstDesc.numRows > 1)) { // Scalar dimension promotion result |= (1 << 0); } - else if ((srcDesc.numDimensions == dstDesc.numDimensions && (srcDesc.numComponents > dstDesc.numComponents || srcDesc.height > dstDesc.height)) || - (srcDesc.numDimensions > 0 && dstDesc.numDimensions == 0)) + else if ((srcDesc.numComponents > dstDesc.numComponents && srcDesc.numRows >= dstDesc.numRows) || + (srcDesc.numComponents >= dstDesc.numComponents && srcDesc.numRows > dstDesc.numRows)) { // Truncation result |= (1 << 4); } - else if (srcDesc.numDimensions != dstDesc.numDimensions || - srcDesc.numComponents != dstDesc.numComponents || - srcDesc.height != dstDesc.height) + else if (srcDesc.numComponents != dstDesc.numComponents || srcDesc.numRows != dstDesc.numRows) { return -1; } @@ -7422,6 +7223,11 @@ static int GetTypeCastRank(HLSLTree * tree, const HLSLType& srcType, const HLSLT } +static bool AreTypesEqual(HLSLTree* tree, const HLSLType& lhs, const HLSLType& rhs) +{ + return GetTypeCastRank(tree, lhs, rhs) == 0; +} + static bool GetFunctionCallCastRanks(HLSLTree* tree, const HLSLFunctionCall* call, const HLSLFunction* function, int* rankBuffer) { // Note theat the arguments do not need to be the same, because of default parameters. @@ -7524,7 +7330,7 @@ static CompareFunctionsResult CompareFunctions(HLSLTree* tree, const HLSLFunctio } -bool HLSLParser::GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& type1, const HLSLType& type2, HLSLType& result) +bool HLSLParser::GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& type1, const HLSLType& type2, HLSLType& argType, HLSLType& resType) { if (type1.baseType < HLSLBaseType_FirstNumeric || type1.baseType > HLSLBaseType_LastNumeric || type1.array || @@ -7541,6 +7347,10 @@ bool HLSLParser::GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& ty } } + argType.baseType = _binaryOpTypeLookup[type1.baseType - HLSLBaseType_FirstNumeric][type2.baseType - HLSLBaseType_FirstNumeric]; + resType.array =false; + resType.flags = 0; + switch (binaryOp) { case HLSLBinaryOp_And: @@ -7552,21 +7362,21 @@ bool HLSLParser::GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& ty case HLSLBinaryOp_Equal: case HLSLBinaryOp_NotEqual: { - int numComponents = std::max( _baseTypeDescriptions[ type1.baseType ].numComponents, _baseTypeDescriptions[ type2.baseType ].numComponents ); - result.baseType = HLSLBaseType( HLSLBaseType_Bool + numComponents - 1 ); + int numComponents = std::max( BASE_TYPE_DESC[ type1.baseType ].numComponents, BASE_TYPE_DESC[ type2.baseType ].numComponents ); + resType.baseType = HLSLBaseType( HLSLBaseType_Bool + numComponents - 1 ); break; } default: - result.baseType = _binaryOpTypeLookup[type1.baseType - HLSLBaseType_FirstNumeric][type2.baseType - HLSLBaseType_FirstNumeric]; + resType.baseType = _binaryOpTypeLookup[type1.baseType - HLSLBaseType_FirstNumeric][type2.baseType - HLSLBaseType_FirstNumeric]; break; } - result.typeName.Reset(); - result.array = false; - result.flags = (type1.flags & type2.flags) & HLSLTypeFlag_Const; // Propagate constness. + resType.typeName.Reset(); + resType.array = false; + resType.flags = (type1.flags & type2.flags) & HLSLTypeFlag_Const; // Propagate constness. - return result.baseType != HLSLBaseType_Unknown; + return resType.baseType != HLSLBaseType_Unknown; } @@ -8583,11 +8393,13 @@ bool HLSLParser::ParseStatement(HLSLStatement*& statement, const HLSLType& retur } // Check that the return expression can be cast to the return type of the function. HLSLType voidType(HLSLBaseType_Void); - if (!CheckTypeCast(returnStatement->expression ? returnStatement->expression->expressionType : voidType, returnType)) + if (!CheckTypeCast(returnType, returnStatement->expression ? returnStatement->expression->expressionType : voidType)) { return false; } + returnStatement->expression = OptionallyApplyImplicitCast(returnType, returnStatement->expression); + statement = returnStatement; return Expect(';'); } @@ -8732,6 +8544,7 @@ bool HLSLParser::ParseDeclarationAssignment(HLSLDeclaration* declaration) { return false; } + declaration->assignment = OptionallyApplyImplicitCast(declaration->type, declaration->assignment); } return true; } @@ -8757,7 +8570,7 @@ bool HLSLParser::ParseFieldDeclaration(HLSLStructField*& field) return Expect(';'); } -bool HLSLParser::CheckTypeCast(const HLSLType& srcType, const HLSLType& dstType) +bool HLSLParser::CheckTypeCast(const HLSLType& dstType, const HLSLType& srcType) { if (GetTypeCastRank(m_tree, srcType, dstType) == -1) { @@ -8820,23 +8633,19 @@ bool HLSLParser::ParseExpression(HLSLExpression*& expression, bool allowCommaOpe return false; } + if (!CheckTypeCast(expression->expressionType, expression2->expressionType)) + { + return false; + } + HLSLBinaryExpression* binaryExpression = m_tree->AddNode(expression->fileName, expression->line); binaryExpression->binaryOp = assignOp; binaryExpression->expression1 = expression; - binaryExpression->expression2 = expression2; + binaryExpression->expression2 = OptionallyApplyImplicitCast(expression->expressionType, expression2); // This type is not strictly correct, since the type should be a reference. // However, for our usage of the types it should be sufficient. binaryExpression->expressionType = expression->expressionType; - if (!CheckTypeCast(expression2->expressionType, expression->expressionType)) - { - const char* srcTypeName = GetCstr(GetTypeName(expression2->expressionType)); - const char* dstTypeName = GetCstr(GetTypeName(expression->expressionType)); - m_pFullTokenizer->Error("Cannot implicitly convert from '%s' to '%s'", srcTypeName, dstTypeName); - - return false; - } - expression = binaryExpression; } @@ -9010,11 +8819,6 @@ bool HLSLParser::ParseBinaryExpression(int priority, HLSLExpression*& expression { return false; } - HLSLBinaryExpression* binaryExpression = m_tree->AddNode(fileName, line); - binaryExpression->binaryOp = binaryOp; - binaryExpression->expression1 = expression; - binaryExpression->expression2 = expression2; - HLSLType exp1Type = expression->expressionType; HLSLType exp2Type = expression2->expressionType; @@ -9044,13 +8848,14 @@ bool HLSLParser::ParseBinaryExpression(int priority, HLSLExpression*& expression exp2Type.baseType = HLSLBaseType_Uint; } - if (!GetBinaryOpResultType( binaryOp, exp1Type, exp2Type, binaryExpression->expressionType )) + HLSLType resType, argType; + if (!GetBinaryOpResultType( binaryOp, exp1Type, exp2Type, argType, resType)) { - const char* typeName1 = GetCstr(GetTypeName( binaryExpression->expression1->expressionType )); - const char* typeName2 = GetCstr(GetTypeName( binaryExpression->expression2->expressionType )); + const char* typeName1 = GetCstr(GetTypeName( expression->expressionType )); + const char* typeName2 = GetCstr(GetTypeName( expression2->expressionType )); // debug - bool temp = GetBinaryOpResultType(binaryOp, exp1Type, exp2Type, binaryExpression->expressionType); + bool temp = GetBinaryOpResultType(binaryOp, exp1Type, exp2Type, argType, resType); m_pFullTokenizer->Error("binary '%s' : no global operator found which takes types '%s' and '%s' (or there is no acceptable conversion)", CHECK_CSTR(GetBinaryOpName(binaryOp)), CHECK_CSTR(typeName1), CHECK_CSTR(typeName2)); @@ -9058,6 +8863,13 @@ bool HLSLParser::ParseBinaryExpression(int priority, HLSLExpression*& expression return false; } + HLSLBinaryExpression* binaryExpression = m_tree->AddNode(fileName, line); + binaryExpression->binaryOp = binaryOp; + binaryExpression->expressionType = resType; + // TODO: should we handle case when arg types can be different. + binaryExpression->expression1 = OptionallyApplyImplicitCast(argType, expression); + binaryExpression->expression2 = OptionallyApplyImplicitCast(argType, expression2); + expression = binaryExpression; } else if (_conditionalOpPriority > priority && Accept('?')) @@ -9149,6 +8961,24 @@ bool HLSLParser::ApplyMemberAccessToNode(HLSLExpression * & expression) return true; } +HLSLExpression* HLSLParser::OptionallyApplyImplicitCast(const HLSLType& dstType, HLSLExpression* expr) +{ + const char* fileName = GetFileName(); + int line = GetLineNumber(); + + if (expr && !AreTypesEqual(m_tree, dstType, expr->expressionType)) + { + HLSLCastingExpression* castExpr = m_tree->AddNode(fileName, line); + castExpr->expressionType = dstType; + castExpr->expression = expr; + castExpr->implicit = true; + return castExpr; + } + + return expr; +} + + bool HLSLParser::ParseFunctionCall(CachedString name, HLSLExpression* object, HLSLExpression*& expression) { const char* fileName = GetFileName(); @@ -9175,6 +9005,11 @@ bool HLSLParser::ParseFunctionCall(CachedString name, HLSLExpression* object, HL } functionCall->function = function; + // Insert implicit casts as AST tree nodes in order to simplify backends + for (size_t i = 0; i < functionCall->params.size(); ++i) + { + functionCall->params[i] = OptionallyApplyImplicitCast(function->args[i]->type, functionCall->params[i]); + } // if it is special function for texture / buffer //TODO move to glsl backend @@ -9413,7 +9248,6 @@ bool HLSLParser::ParseTerminalExpression(HLSLExpression*& expression, bool& need { // Case 1. HLSLCastingExpression* castingExpression = m_tree->AddNode(fileName, line); - castingExpression->type = type; expression = castingExpression; castingExpression->expressionType = type; @@ -10043,7 +9877,7 @@ bool HLSLParser::ParseArguments(eastl::vector& argVec) return false; } - if (Accept('=') && !ParseExpression(argument->defaultValue,false,0)) + if (Accept('=') && !ParseExpression(argument->defaultValue, false, 0)) { // @@ Print error! return false; @@ -11554,11 +11388,6 @@ HLSLFunction* HLSLParser::FindFunction(const CachedString & name) return NULL; } -static bool AreTypesEqual(HLSLTree* tree, const HLSLType& lhs, const HLSLType& rhs) -{ - return GetTypeCastRank(tree, lhs, rhs) == 0; -} - static bool AreArgumentListsEqualVec(HLSLTree* tree, const eastl::vector & lhsVec, const eastl::vector & rhsVec) { if (lhsVec.size() != rhsVec.size()) @@ -11843,7 +11672,7 @@ bool HLSLParser::GetMemberType(HLSLType& objectType, HLSLMemberAccess * memberAc return true; } } - if (_baseTypeDescriptions[comparingType].numericType == NumericType_NaN) + if (BASE_TYPE_DESC[comparingType].numericType == NumericType_NaN) { // Currently we don't have an non-numeric types that allow member access. return false; @@ -11851,7 +11680,7 @@ bool HLSLParser::GetMemberType(HLSLType& objectType, HLSLMemberAccess * memberAc int swizzleLength = 0; - if (_baseTypeDescriptions[comparingType].numDimensions <= 1) + if (BASE_TYPE_DESC[comparingType].numRows == 1) { eastl::string fullFieldName = GetCstr(fieldName); // Check for a swizzle on the scalar/vector types. @@ -11889,8 +11718,8 @@ bool HLSLParser::GetMemberType(HLSLType& objectType, HLSLMemberAccess * memberAc int r = (n[0] - '0') - base; int c = (n[1] - '0') - base; - if (r >= _baseTypeDescriptions[comparingType].height || - c >= _baseTypeDescriptions[comparingType].numComponents) + if (r >= BASE_TYPE_DESC[comparingType].numRows || + c >= BASE_TYPE_DESC[comparingType].numComponents) { return false; } @@ -11921,7 +11750,7 @@ bool HLSLParser::GetMemberType(HLSLType& objectType, HLSLMemberAccess * memberAc static const HLSLBaseType boolType[] = { HLSLBaseType_Bool, HLSLBaseType_Bool2, HLSLBaseType_Bool3, HLSLBaseType_Bool4 }; - switch (_baseTypeDescriptions[comparingType].numericType) + switch (BASE_TYPE_DESC[comparingType].numericType) { case NumericType_Float: memberAccess->expressionType.baseType = floatType[swizzleLength - 1]; diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.h b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.h index 8c872508c3..955a7d223c 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.h +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLParser.h @@ -79,18 +79,7 @@ class HLSLParser const char * GetCstr(const CachedString & currStr) const; - //void RevertParentStackToSize(int dstSize) - //{ - // m_parentStackIdentifiers.resize(dstSize); - //} - - //int GetParentStackSize() const - //{ - // return (int)m_parentStackIdentifiers.size(); - //} - - static bool GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& type1, const HLSLType& type2, HLSLType& result); - + static bool GetBinaryOpResultType(HLSLBinaryOp binaryOp, const HLSLType& type1, const HLSLType& type2, HLSLType& argType, HLSLType& resType); private: @@ -159,6 +148,8 @@ class HLSLParser bool ParsePipeline(HLSLStatement*& pipeline); bool ParseStage(HLSLStatement*& stage); + HLSLExpression* OptionallyApplyImplicitCast(const HLSLType& dstType, HLSLExpression* expr); + bool ParseAttributeList(HLSLAttribute*& attribute); bool ParseAttributeBlock(HLSLAttribute*& attribute); diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.cpp b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.cpp index 9cece99a88..dc75606b33 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.cpp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.cpp @@ -3,6 +3,176 @@ #include "HLSLTree.h" #include "StringLibrary.h" +const BaseTypeDescription BASE_TYPE_DESC[HLSLBaseType_Count] = + { + { "unknown type", NumericType_NaN, 0, 0, -1 }, // HLSLBaseType_Unknown + { "void", NumericType_NaN, 0, 0, -1 }, // HLSLBaseType_Void + + { "float", NumericType_Float, 1, 1, 0 }, // HLSLBaseType_Float + { "float1x2", NumericType_Float, 1, 2, 0 }, // HLSLBaseType_Float1x2 + { "float1x3", NumericType_Float, 1, 3, 0 }, // HLSLBaseType_Float1x3 + { "float1x4", NumericType_Float, 1, 4, 0 }, // HLSLBaseType_Float1x4 + { "float2", NumericType_Float, 2, 1, 0 }, // HLSLBaseType_Float2 + { "float2x2", NumericType_Float, 2, 2, 0 }, // HLSLBaseType_Float2x2 + { "float2x3", NumericType_Float, 2, 3, 0 }, // HLSLBaseType_Float2x3 + { "float2x4", NumericType_Float, 2, 4, 0 }, // HLSLBaseType_Float2x4 + { "float3", NumericType_Float, 3, 1, 0 }, // HLSLBaseType_Float3 + { "float3x2", NumericType_Float, 3, 2, 0 }, // HLSLBaseType_Float3x2 + { "float3x3", NumericType_Float, 3, 3, 0 }, // HLSLBaseType_Float3x3 + { "float3x4", NumericType_Float, 3, 4, 0 }, // HLSLBaseType_Float3x4 + { "float4", NumericType_Float, 4, 1, 0 }, // HLSLBaseType_Float4 + { "float4x2", NumericType_Float, 4, 2, 0 }, // HLSLBaseType_Float4x2 + { "float4x3", NumericType_Float, 4, 3, 0 }, // HLSLBaseType_Float4x3 + { "float4x4", NumericType_Float, 4, 4, 0 }, // HLSLBaseType_Float4x4 + + + { "half", NumericType_Half, 1, 1, 1 }, // HLSLBaseType_Half + { "half1x2", NumericType_Half, 1, 2, 1 }, // HLSLBaseType_Half1x2 + { "half1x3", NumericType_Half, 1, 3, 1 }, // HLSLBaseType_Half1x3 + { "half1x4", NumericType_Half, 1, 4, 1 }, // HLSLBaseType_Half1x4 + { "half2", NumericType_Half, 2, 1, 1 }, // HLSLBaseType_Half2 + { "half2x2", NumericType_Half, 2, 2, 1 }, // HLSLBaseType_Half2x2 + { "half2x3", NumericType_Half, 2, 3, 1 }, // HLSLBaseType_Half2x3 + { "half2x4", NumericType_Half, 2, 4, 1 }, // HLSLBaseType_Half2x4 + { "half3", NumericType_Half, 3, 1, 1 }, // HLSLBaseType_Half3 + { "half3x2", NumericType_Half, 3, 2, 1 }, // HLSLBaseType_Half3x2 + { "half3x3", NumericType_Half, 3, 3, 1 }, // HLSLBaseType_Half3x3 + { "half3x4", NumericType_Half, 3, 4, 1 }, // HLSLBaseType_Half3x4 + { "half4", NumericType_Half, 4, 1, 1 }, // HLSLBaseType_Half4 + { "half4x2", NumericType_Half, 4, 2, 1 }, // HLSLBaseType_Half4x2 + { "half4x3", NumericType_Half, 4, 3, 1 }, // HLSLBaseType_Half4x3 + { "half4x4", NumericType_Half, 4, 4, 1 }, // HLSLBaseType_Half4x4 + + + { "min16float", NumericType_Min16Float, 1, 1, 1 }, // HLSLBaseType_Min16Float + { "min16float1x2", NumericType_Min16Float, 1, 2, 1 }, // HLSLBaseType_Min16Float1x2 + { "min16float1x3", NumericType_Min16Float, 1, 3, 1 }, // HLSLBaseType_Min16Float1x3 + { "min16float1x4", NumericType_Min16Float, 1, 4, 1 }, // HLSLBaseType_Min16Float1x4 + { "min16float2", NumericType_Min16Float, 2, 1, 1 }, // HLSLBaseType_Min16Float2 + { "min16float2x2", NumericType_Min16Float, 2, 2, 1 }, // HLSLBaseType_Min16Float2x2 + { "min16float2x3", NumericType_Min16Float, 2, 3, 1 }, // HLSLBaseType_Min16Float2x3 + { "min16float2x4", NumericType_Min16Float, 2, 4, 1 }, // HLSLBaseType_Min16Float2x4 + { "min16float3", NumericType_Min16Float, 3, 1, 1 }, // HLSLBaseType_Min16Float3 + { "min16float3x2", NumericType_Min16Float, 3, 2, 1 }, // HLSLBaseType_Min16Float3x2 + { "min16float3x3", NumericType_Min16Float, 3, 3, 1 }, // HLSLBaseType_Min16Float3x3 + { "min16float3x4", NumericType_Min16Float, 3, 4, 1 }, // HLSLBaseType_Min16Float3x4 + { "min16float4", NumericType_Min16Float, 4, 1, 1 }, // HLSLBaseType_Min16Float4 + { "min16float4x2", NumericType_Min16Float, 4, 2, 1 }, // HLSLBaseType_Min16Float4x2 + { "min16float4x3", NumericType_Min16Float, 4, 3, 1 }, // HLSLBaseType_Min16Float4x3 + { "min16float4x4", NumericType_Min16Float, 4, 4, 1 }, // HLSLBaseType_Min16Float4x4 + + + { "min10float", NumericType_Min10Float, 1, 1, 1 }, // HLSLBaseType_Min10Float + { "min10float1x2", NumericType_Min10Float, 1, 2, 1 }, // HLSLBaseType_Min10Float1x2 + { "min10float1x3", NumericType_Min10Float, 1, 3, 1 }, // HLSLBaseType_Min10Float1x3 + { "min10float1x4", NumericType_Min10Float, 1, 4, 1 }, // HLSLBaseType_Min10Float1x4 + { "min10float2", NumericType_Min10Float, 2, 1, 1 }, // HLSLBaseType_Min10Float2 + { "min10float2x2", NumericType_Min10Float, 2, 2, 1 }, // HLSLBaseType_Min10Float2x2 + { "min10float2x3", NumericType_Min10Float, 2, 3, 1 }, // HLSLBaseType_Min10Float2x3 + { "min10float2x4", NumericType_Min10Float, 2, 4, 1 }, // HLSLBaseType_Min10Float2x4 + { "min10float3", NumericType_Min10Float, 3, 1, 1 }, // HLSLBaseType_Min10Float3 + { "min10float3x2", NumericType_Min10Float, 3, 2, 1 }, // HLSLBaseType_Min10Float3x2 + { "min10float3x3", NumericType_Min10Float, 3, 3, 1 }, // HLSLBaseType_Min10Float3x3 + { "min10float3x4", NumericType_Min10Float, 3, 4, 1 }, // HLSLBaseType_Min10Float3x4 + { "min10float4", NumericType_Min10Float, 4, 1, 1 }, // HLSLBaseType_Min10Float4 + { "min10float4x2", NumericType_Min10Float, 4, 2, 1 }, // HLSLBaseType_Min10Float4x2 + { "min10float4x3", NumericType_Min10Float, 4, 3, 1 }, // HLSLBaseType_Min10Float4x3 + { "min10float4x4", NumericType_Min10Float, 4, 4, 1 }, // HLSLBaseType_Min10Float4x4 + + { "bool", NumericType_Bool, 1, 1, 4 }, // HLSLBaseType_Bool + { "bool1x2", NumericType_Bool, 1, 2, 4 }, // HLSLBaseType_Bool1x2 + { "bool1x3", NumericType_Bool, 1, 3, 4 }, // HLSLBaseType_Bool1x3 + { "bool1x4", NumericType_Bool, 1, 4, 4 }, // HLSLBaseType_Bool1x4 + { "bool2", NumericType_Bool, 2, 1, 4 }, // HLSLBaseType_Bool2 + { "bool2x2", NumericType_Bool, 2, 2, 4 }, // HLSLBaseType_Bool1x2 + { "bool2x3", NumericType_Bool, 2, 3, 4 }, // HLSLBaseType_Bool1x3 + { "bool2x4", NumericType_Bool, 2, 4, 4 }, // HLSLBaseType_Bool1x4 + { "bool3", NumericType_Bool, 3, 1, 4 }, // HLSLBaseType_Bool3 + { "bool3x2", NumericType_Bool, 3, 2, 4 }, // HLSLBaseType_Bool1x2 + { "bool3x3", NumericType_Bool, 3, 3, 4 }, // HLSLBaseType_Bool1x3 + { "bool3x4", NumericType_Bool, 3, 4, 4 }, // HLSLBaseType_Bool1x4 + { "bool4", NumericType_Bool, 4, 1, 4 }, // HLSLBaseType_Bool4 + { "bool4x2", NumericType_Bool, 4, 2, 4 }, // HLSLBaseType_Bool1x2 + { "bool4x3", NumericType_Bool, 4, 3, 4 }, // HLSLBaseType_Bool1x3 + { "bool4x4", NumericType_Bool, 4, 4, 4 }, // HLSLBaseType_Bool1x4 + + { "int", NumericType_Int, 1, 1, 3 }, // HLSLBaseType_Int + { "int1x2", NumericType_Int, 1, 2, 3 }, // HLSLBaseType_Int1x2 + { "int1x3", NumericType_Int, 1, 3, 3 }, // HLSLBaseType_Int1x3 + { "int1x4", NumericType_Int, 1, 4, 3 }, // HLSLBaseType_Int1x4 + { "int2", NumericType_Int, 2, 1, 3 }, // HLSLBaseType_Int2 + { "int2x2", NumericType_Int, 2, 2, 3 }, // HLSLBaseType_Int2x2 + { "int2x3", NumericType_Int, 2, 3, 3 }, // HLSLBaseType_Int2x3 + { "int2x4", NumericType_Int, 2, 4, 3 }, // HLSLBaseType_Int2x4 + { "int3", NumericType_Int, 3, 1, 3 }, // HLSLBaseType_Int3 + { "int3x2", NumericType_Int, 3, 2, 3 }, // HLSLBaseType_Int3x2 + { "int3x3", NumericType_Int, 3, 3, 3 }, // HLSLBaseType_Int3x3 + { "int3x4", NumericType_Int, 3, 4, 3 }, // HLSLBaseType_Int3x4 + { "int4", NumericType_Int, 4, 1, 3 }, // HLSLBaseType_Int4 + { "int4x2", NumericType_Int, 4, 2, 3 }, // HLSLBaseType_Int4x2 + { "int4x3", NumericType_Int, 4, 3, 3 }, // HLSLBaseType_Int4x3 + { "int4x4", NumericType_Int, 4, 4, 3 }, // HLSLBaseType_Int4x4 + + { "uint", NumericType_Uint, 1, 1, 2 }, // HLSLBaseType_Uint + { "uint1x2", NumericType_Uint, 1, 2, 2 }, // HLSLBaseType_Int1x2 + { "uint1x3", NumericType_Uint, 1, 3, 2 }, // HLSLBaseType_Int1x3 + { "uint1x4", NumericType_Uint, 1, 4, 2 }, // HLSLBaseType_Int1x4 + { "uint2", NumericType_Uint, 2, 1, 2 }, // HLSLBaseType_Uint2 + { "uint2x2", NumericType_Uint, 1, 2, 2 }, // HLSLBaseType_Uint1x2 + { "uint2x3", NumericType_Uint, 1, 3, 2 }, // HLSLBaseType_Uint1x3 + { "uint2x4", NumericType_Uint, 1, 4, 2 }, // HLSLBaseType_Uint1x4 + { "uint3", NumericType_Uint, 3, 1, 2 }, // HLSLBaseType_Uint3 + { "uint3x2", NumericType_Uint, 1, 2, 2 }, // HLSLBaseType_Uint1x2 + { "uint3x3", NumericType_Uint, 1, 3, 2 }, // HLSLBaseType_Uint1x3 + { "uint3x4", NumericType_Uint, 1, 4, 2 }, // HLSLBaseType_Uint1x4 + { "uint4", NumericType_Uint, 4, 1, 2 }, // HLSLBaseType_Uint4 + { "uint4x2", NumericType_Uint, 1, 2, 2 }, // HLSLBaseType_Uint1x2 + { "uint4x3", NumericType_Uint, 1, 3, 2 }, // HLSLBaseType_Uint1x3 + { "uint4x4", NumericType_Uint, 1, 4, 2 }, // HLSLBaseType_Uint1x4 + + + { "inputPatch", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_InputPatch + { "outputPatch", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_OutputPatch + + { "pointStream", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_PointStream + { "lineStream", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_LineStream + { "triangleStream", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_TriangleStream + + { "point", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Point + { "line", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Line + { "triangle", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Triangle + { "lineadj", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Lineadj + { "triangleadj", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Triangleadj + + { "texture", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture + { "Texture1D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture1D + { "Texture1DArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture1DArray + { "Texture2D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture2D + { "Texture2DArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture2DArray + { "Texture3D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture3D + { "Texture2DMS", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture2DMS + { "Texture2DMSArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Texture2DMSArray + { "TextureCube", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_TextureCube + { "TextureCubeArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_TextureCubeArray + + { "RWTexture1D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_RWTexture1D + { "RWTexture1DArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_RWTexture1DArray + { "RWTexture2D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_RWTexture2D + { "RWTexture2DArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_RWTexture2DArray + { "RWTexture3D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_RWTexture3D + + + { "sampler", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Sampler + { "sampler2D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Sampler2D + { "sampler3D", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Sampler3D + { "samplerCUBE", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_SamplerCube + { "sampler2DShadow", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Sampler2DShadow + { "sampler2DMS", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Sampler2DMS + { "sampler2DArray", NumericType_NaN, 1, 0, -1 }, // HLSLBaseType_Sampler2DArray + { "user defined", NumericType_NaN, 1, 0, -1 } // HLSLBaseType_UserDefined + }; + + const char * FetchCstr(const StringLibrary * stringLibrary, const CachedString & cstr) { ASSERT_PARSER(stringLibrary != NULL); @@ -1485,7 +1655,7 @@ void HLSLTreeVisitor::VisitConditionalExpression(HLSLConditionalExpression * nod void HLSLTreeVisitor::VisitCastingExpression(HLSLCastingExpression * node) { - VisitType(node->type); + VisitType(node->expressionType); VisitExpression(node->expression); } @@ -1836,183 +2006,6 @@ void AddSingleStatement(HLSLRoot * root, HLSLStatement * before, HLSLStatement * AddStatements(root, before, statement, statement); } -// @@ This is very game-specific. Should be moved to pipeline_parser or somewhere else. -void GroupParameters(HLSLTree * tree) -{ - // Sort parameters based on semantic and group them in cbuffers. - HLSLRoot* root = tree->GetRoot(); - - HLSLDeclaration * firstPerItemDeclaration = NULL; - HLSLDeclaration * lastPerItemDeclaration = NULL; - - HLSLDeclaration * instanceDataDeclaration = NULL; - - HLSLDeclaration * firstPerPassDeclaration = NULL; - HLSLDeclaration * lastPerPassDeclaration = NULL; - - HLSLDeclaration * firstPerItemSampler = NULL; - HLSLDeclaration * lastPerItemSampler = NULL; - - HLSLDeclaration * firstPerPassSampler = NULL; - HLSLDeclaration * lastPerPassSampler = NULL; - - HLSLStatement * statementBeforeBuffers = NULL; - - HLSLStatement* previousStatement = NULL; - HLSLStatement* statement = root->statement; - while (statement != NULL) - { - HLSLStatement* nextStatement = statement->nextStatement; - - if (statement->nodeType == HLSLNodeType_Struct) // Do not remove this, or it will mess the else clause below. - { - statementBeforeBuffers = statement; - } - else if (statement->nodeType == HLSLNodeType_Declaration) - { - HLSLDeclaration* declaration = (HLSLDeclaration*)statement; - - // We insert buffers after the last const declaration. - if ((declaration->type.flags & HLSLTypeFlag_Const) != 0) - { - statementBeforeBuffers = statement; - } - - // Do not move samplers or static/const parameters. - if ((declaration->type.flags & (HLSLTypeFlag_Static|HLSLTypeFlag_Const)) == 0) - { - // Unlink statement. - statement->nextStatement = NULL; - if (previousStatement != NULL) previousStatement->nextStatement = nextStatement; - else root->statement = nextStatement; - - while(declaration != NULL) - { - HLSLDeclaration* nextDeclaration = declaration->nextDeclaration; - - eastl::string semanticName = FetchCstr(tree->m_stringLibrary,declaration->semantic); - if (declaration->semantic.IsNotEmpty() && String_EqualNoCase(semanticName.c_str(), "PER_INSTANCED_ITEM")) - { - ASSERT_PARSER(instanceDataDeclaration == NULL); - instanceDataDeclaration = declaration; - } - else - { - // Select group based on type and semantic. - HLSLDeclaration ** first, ** last; - if (declaration->semantic.IsEmpty() || String_EqualNoCase(semanticName.c_str(), "PER_ITEM") || String_EqualNoCase(semanticName.c_str(), "PER_MATERIAL")) - { - if (IsSamplerType(declaration->type)) - { - first = &firstPerItemSampler; - last = &lastPerItemSampler; - } - else - { - first = &firstPerItemDeclaration; - last = &lastPerItemDeclaration; - } - } - else - { - if (IsSamplerType(declaration->type)) - { - first = &firstPerPassSampler; - last = &lastPerPassSampler; - } - else - { - first = &firstPerPassDeclaration; - last = &lastPerPassDeclaration; - } - } - - // Add declaration to new list. - if (*first == NULL) *first = declaration; - else (*last)->nextStatement = declaration; - *last = declaration; - } - - // Unlink from declaration list. - declaration->nextDeclaration = NULL; - - // Reset attributes. - declaration->registerName.Reset(); - - declaration = nextDeclaration; - } - } - } - - if (statement->nextStatement == nextStatement) { - previousStatement = statement; - } - statement = nextStatement; - } - - - // Add instance data declaration at the end of the per_item buffer. - if (instanceDataDeclaration != NULL) - { - if (firstPerItemDeclaration == NULL) firstPerItemDeclaration = instanceDataDeclaration; - else lastPerItemDeclaration->nextStatement = instanceDataDeclaration; - } - - // Add samplers. - if (firstPerItemSampler != NULL) { - AddStatements(root, statementBeforeBuffers, firstPerItemSampler, lastPerItemSampler); - statementBeforeBuffers = lastPerItemSampler; - } - if (firstPerPassSampler != NULL) { - AddStatements(root, statementBeforeBuffers, firstPerPassSampler, lastPerPassSampler); - statementBeforeBuffers = lastPerPassSampler; - } - - // @@ We are assuming per_item and per_pass buffers don't already exist. @@ We should assert on that. - - if (firstPerItemDeclaration != NULL) - { - // Create buffer statement. - HLSLBuffer * perItemBuffer = tree->AddNode(firstPerItemDeclaration->fileName, firstPerItemDeclaration->line-1); - perItemBuffer->name = tree->AddStringCached("per_item"); - perItemBuffer->registerName = tree->AddStringCached("b0"); - perItemBuffer->field = firstPerItemDeclaration; - - // Set declaration buffer pointers. - HLSLDeclaration * field = perItemBuffer->field; - while (field != NULL) - { - field->buffer = perItemBuffer; - field = (HLSLDeclaration *)field->nextStatement; - } - - // Add buffer to statements. - AddSingleStatement(root, statementBeforeBuffers, perItemBuffer); - statementBeforeBuffers = perItemBuffer; - } - - if (firstPerPassDeclaration != NULL) - { - // Create buffer statement. - HLSLBuffer * perPassBuffer = tree->AddNode(firstPerPassDeclaration->fileName, firstPerPassDeclaration->line-1); - perPassBuffer->name = tree->AddStringCached("per_pass"); - perPassBuffer->registerName = tree->AddStringCached("b1"); - perPassBuffer->field = firstPerPassDeclaration; - - // Set declaration buffer pointers. - HLSLDeclaration * field = perPassBuffer->field; - while (field != NULL) - { - field->buffer = perPassBuffer; - field = (HLSLDeclaration *)field->nextStatement; - } - - // Add buffer to statements. - AddSingleStatement(root, statementBeforeBuffers, perPassBuffer); - } -} - - class FindArgumentVisitor : public HLSLTreeVisitor { public: diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.h b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.h index 6ef64c5fbd..f4985bb1cf 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.h +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/HLSLTree.h @@ -140,7 +140,7 @@ enum HLSLNodeType enum HLSLBaseType { HLSLBaseType_Unknown, - HLSLBaseType_Void, + HLSLBaseType_Void, HLSLBaseType_Float, HLSLBaseType_FirstNumeric = HLSLBaseType_Float, @@ -175,8 +175,7 @@ enum HLSLBaseType HLSLBaseType_Half4, HLSLBaseType_Half4x2, HLSLBaseType_Half4x3, - HLSLBaseType_Half4x4, - + HLSLBaseType_Half4x4, HLSLBaseType_Min16Float, HLSLBaseType_Min16Float1x2, @@ -212,7 +211,7 @@ enum HLSLBaseType HLSLBaseType_Min10Float4x3, HLSLBaseType_Min10Float4x4, - HLSLBaseType_Bool, + HLSLBaseType_Bool, HLSLBaseType_FirstInteger = HLSLBaseType_Bool, HLSLBaseType_Bool1x2, HLSLBaseType_Bool1x3, @@ -756,6 +755,29 @@ enum HLSLAttributeType }; +enum NumericType +{ + NumericType_Float, + NumericType_Half, + NumericType_Min16Float, + NumericType_Min10Float, + NumericType_Bool, + NumericType_Int, + NumericType_Uint, + NumericType_Count, + NumericType_NaN, +}; + +struct BaseTypeDescription +{ + const char* typeName; + NumericType numericType; + int numComponents; + int numRows; + int binaryOpRank; +}; + +extern const BaseTypeDescription BASE_TYPE_DESC[HLSLBaseType_Count]; enum HLSLAddressSpace { @@ -920,7 +942,7 @@ inline bool IsRWTexture(HLSLBaseType type) } } -inline bool IsRWBuffer(HLSLBaseType type) +inline bool IsBuffer(HLSLBaseType type) { switch (type) { @@ -936,6 +958,35 @@ inline bool IsRWBuffer(HLSLBaseType type) } } +inline bool IsStructuredBuffer(HLSLBaseType type) +{ + switch (type) + { + case HLSLBaseType_StructuredBuffer: + case HLSLBaseType_PureBuffer: + case HLSLBaseType_RWBuffer: + case HLSLBaseType_RWStructuredBuffer: + case HLSLBaseType_RasterizerOrderedBuffer: + case HLSLBaseType_RasterizerOrderedStructuredBuffer: + return true; + default: + return false; + } +} + +inline bool IsRWBuffer(HLSLBaseType type) +{ + switch (type) + { + case HLSLBaseType_RWBuffer: + case HLSLBaseType_RWStructuredBuffer: + case HLSLBaseType_RWByteAddressBuffer: + return true; + default: + return false; + } +} + inline bool IsRasterizerOrderedTexture(HLSLBaseType type) { switch (type) @@ -1431,13 +1482,10 @@ struct HLSLConditionalExpression : public HLSLExpression struct HLSLCastingExpression : public HLSLExpression { - static const HLSLNodeType s_type = HLSLNodeType_CastingExpression; - HLSLCastingExpression() - { - expression = NULL; - } - HLSLType type; - HLSLExpression* expression; + static const HLSLNodeType s_type = HLSLNodeType_CastingExpression; + + HLSLExpression* expression = NULL; + bool implicit = false; }; /** Float, integer, boolean, etc. literal constant. */ @@ -1735,7 +1783,6 @@ class HLSLTreeVisitor // Tree transformations: extern void PruneTree(HLSLTree* tree, const char* entryName0, const char* entryName1 = NULL); extern void SortTree(HLSLTree* tree); -extern void GroupParameters(HLSLTree* tree); extern void HideUnusedArguments(HLSLFunction * function); extern bool EmulateAlphaTest(HLSLTree* tree, const char* entryName, float alphaRef = 0.5f); diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.cpp b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.cpp index c1e7425c54..bad58ac02c 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.cpp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.cpp @@ -16,6 +16,8 @@ #include #include "StringLibrary.h" +#include "../../../EASTL/sort.h" + static const HLSLType kFloatType(HLSLBaseType_Float); static const HLSLType kUintType(HLSLBaseType_Uint); static const HLSLType kIntType(HLSLBaseType_Int); @@ -23,6 +25,9 @@ static const HLSLType kBoolType(HLSLBaseType_Bool); #define DEFAULT_TEXTURE_COUNT 256 +int TypeArraySize(HLSLType& type); +void AssignRegisters(HLSLRoot* root, const eastl::vector& shiftVec); + // MSL limitations: // - Passing swizzled expressions as out or inout arguments. Out arguments are passed by reference in C++, but // swizzled expressions are not addressable. @@ -180,27 +185,180 @@ CachedString MSLGenerator::GetTypeName(const HLSLType& type) case HLSLBaseType_Texture: return MakeCached("texture"); - case HLSLBaseType_Texture1D: return MakeCached("texture1d"); - case HLSLBaseType_Texture1DArray: return MakeCached("texture1d_array"); - case HLSLBaseType_Texture2D: return MakeCached("texture2d"); - case HLSLBaseType_Texture2DArray: return MakeCached("texture2d_array"); - case HLSLBaseType_Texture3D: return MakeCached("texture3d"); - case HLSLBaseType_Texture2DMS: return MakeCached("texture2d_ms"); - case HLSLBaseType_Texture2DMSArray: return MakeCached("texture2d_ms_array"); - case HLSLBaseType_TextureCube: return MakeCached("texturecube"); - case HLSLBaseType_TextureCubeArray: return MakeCached("texturecube_array"); - - case HLSLBaseType_RasterizerOrderedTexture1D: return MakeCached("texture1d"); - case HLSLBaseType_RasterizerOrderedTexture1DArray: return MakeCached("texture1d_array"); - case HLSLBaseType_RasterizerOrderedTexture2D: return MakeCached("texture2d"); - case HLSLBaseType_RasterizerOrderedTexture2DArray: return MakeCached("texture2d_array"); - case HLSLBaseType_RasterizerOrderedTexture3D: return MakeCached("texture3d"); - - case HLSLBaseType_RWTexture1D: return MakeCached("texture1d"); - case HLSLBaseType_RWTexture1DArray: return MakeCached("texture1d_array"); - case HLSLBaseType_RWTexture2D: return MakeCached("texture2d"); - case HLSLBaseType_RWTexture2DArray: return MakeCached("texture2d_array"); - case HLSLBaseType_RWTexture3D: return MakeCached("texture3d"); + case HLSLBaseType_Texture1D: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture1d"); + case HLSLBaseType_Int: return MakeCached("texture1d"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture1d"); + } + return MakeCached("texture1d"); + } + case HLSLBaseType_Texture1DArray: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture1d_array"); + case HLSLBaseType_Int: return MakeCached("texture1d_array"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture1d_array"); + } + return MakeCached("texture1d_array"); + } + case HLSLBaseType_Texture2D: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture2d"); + case HLSLBaseType_Int: return MakeCached("texture2d"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture2d"); + } + return MakeCached("texture2d"); + } + case HLSLBaseType_Texture2DArray: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture2d_array"); + case HLSLBaseType_Int: return MakeCached("texture2d_array"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture2d_array"); + } + return MakeCached("texture2d_array"); + } + case HLSLBaseType_Texture3D: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture3d"); + case HLSLBaseType_Int: return MakeCached("texture3d"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture3d"); + } + return MakeCached("texture3d"); + } + case HLSLBaseType_Texture2DMS: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture2d_ms"); + case HLSLBaseType_Int: return MakeCached("texture2d_ms"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture2d_ms"); + } + return MakeCached("texture2d_ms"); + } + case HLSLBaseType_Texture2DMSArray: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture2d_ms_array"); + case HLSLBaseType_Int: return MakeCached("texture2d_ms_array"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture2d_ms_array"); + } + return MakeCached("texture2d_ms_array"); + } + case HLSLBaseType_TextureCube: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texturecube"); + case HLSLBaseType_Int: return MakeCached("texturecube"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texturecube"); + } + return MakeCached("texturecube"); + } + case HLSLBaseType_TextureCubeArray: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texturecube_array"); + case HLSLBaseType_Int: return MakeCached("texturecube_array"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texturecube_array"); + } + return MakeCached("texturecube_array"); + } + + case HLSLBaseType_RWTexture1D: + case HLSLBaseType_RasterizerOrderedTexture1D: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture1d"); + case HLSLBaseType_Int: return MakeCached("texture1d"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture1d"); + } + return MakeCached("texture1d"); + } + case HLSLBaseType_RWTexture1DArray: + case HLSLBaseType_RasterizerOrderedTexture1DArray: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture1d_array"); + case HLSLBaseType_Int: return MakeCached("texture1d_array"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture1d_array"); + } + return MakeCached("texture1d_array"); + } + case HLSLBaseType_RWTexture2D: + case HLSLBaseType_RasterizerOrderedTexture2D: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture2d"); + case HLSLBaseType_Int: return MakeCached("texture2d"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture2d"); + } + return MakeCached("texture2d"); + } + case HLSLBaseType_RasterizerOrderedTexture2DArray: + case HLSLBaseType_RWTexture2DArray: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture2d_array"); + case HLSLBaseType_Int: return MakeCached("texture2d_array"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture2d_array"); + } + return MakeCached("texture2d_array"); + } + case HLSLBaseType_RasterizerOrderedTexture3D: + case HLSLBaseType_RWTexture3D: + { + switch (GetScalarBaseType(type.elementType)) + { + case HLSLBaseType_Uint: return MakeCached("texture3d"); + case HLSLBaseType_Int: return MakeCached("texture3d"); + case HLSLBaseType_Half: + case HLSLBaseType_Min16Float: + return MakeCached("texture3d"); + } + return MakeCached("texture3d"); + } case HLSLBaseType_DepthTexture2D: return MakeCached("depth2d"); case HLSLBaseType_DepthTexture2DArray: return MakeCached("depth2d_array"); @@ -275,16 +433,8 @@ MSLGenerator::MSLGenerator() m_target = Target_VertexShader; m_error = false; - m_firstClassArgument = NULL; - m_lastClassArgument = NULL; - attributeCounter = 0; - m_RWBuffers.clear(); - m_RWStructuredBuffers.clear(); - m_PushConstantBuffers.clear(); - m_StructBuffers.clear(); - m_stringLibrary = NULL; } @@ -306,20 +456,6 @@ void MSLGenerator::Error(const char* format, ...) va_end(arg); } -inline void MSLGenerator::AddClassArgument(ClassArgument* arg) -{ - if (m_firstClassArgument == NULL) - { - m_firstClassArgument = arg; - } - else - { - m_lastClassArgument->nextArg = arg; - } - m_lastClassArgument = arg; -} - - class FindGlobalVisitor : public HLSLTreeVisitor { public: @@ -555,591 +691,6 @@ void MSLGenerator::Prepass(HLSLTree* tree, Target target, HLSLFunction* entryFun } bool keepUnused = false; - while (statement != NULL) - { - if (statement->nodeType == HLSLNodeType_Declaration) - { - HLSLDeclaration* declaration = (HLSLDeclaration*)statement; - - if (!declaration->hidden && IsSamplerType(declaration->type)) - { - bool isUsed = usedNames.HasString(declaration->name.m_string); - if (keepUnused || isUsed) - { - //int textureRegister = ParseRegister(declaration->registerName, nextTextureRegister) + m_options.textureRegisterOffset; - //int textureRegister = nextTextureRegister++ + m_options.textureRegisterOffset; - //int textureRegister = nextTextureRegister + m_options.textureRegisterOffset; - //nextTextureRegister++; - int textureRegister = GetTextureRegister(declaration->name); - - CachedString textureName = m_tree->AddStringFormatCached("%s_texture", RawStr(declaration->name)); - CachedString textureRegisterName = m_tree->AddStringFormatCached("texture(%d)", textureRegister); - AddClassArgument(new ClassArgument(textureName, declaration->type, textureRegisterName)); - - if (declaration->type.baseType != HLSLBaseType_Sampler2DMS) - { - //int samplerRegister = nextSamplerRegister++; - // not sure if this is right - int samplerRegister = GetTextureRegister(declaration->name); - - CachedString samplerName = m_tree->AddStringFormatCached("%s_sampler", RawStr(declaration->name)); - CachedString samplerRegisterName = m_tree->AddStringFormatCached("sampler(%d)", samplerRegister); - AddClassArgument(new ClassArgument(samplerName, samplerType, samplerRegisterName)); - } - } - } - } - else if (statement->nodeType == HLSLNodeType_Buffer) - { - HLSLBuffer * buffer = (HLSLBuffer *)statement; - - if (buffer->type.baseType == HLSLBaseType_CBuffer || - buffer->type.baseType == HLSLBaseType_TBuffer) - { - - bool isUsed = usedNames.HasString(buffer->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type(HLSLBaseType_UserDefined); - type.addressSpace = HLSLAddressSpace_Constant; - - - type.typeName = m_tree->AddStringFormatCached("Uniforms_%s", RawStr(buffer->name)); - - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName)); - } - } - if (buffer->type.baseType == HLSLBaseType_ConstantBuffer) - { - bool isUsed = usedNames.HasString(buffer->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type(HLSLBaseType_UserDefined); - type.addressSpace = HLSLAddressSpace_Constant; - - - if (buffer->bPushConstant) - { - m_PushConstantBuffers.push_back(buffer); - } - - type.typeName = m_tree->AddStringFormatCached("Uniforms_%s", RawStr(buffer->name)); - - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName)); - } - } - else if (buffer->type.baseType == HLSLBaseType_ByteAddressBuffer || buffer->type.baseType == HLSLBaseType_RWByteAddressBuffer || buffer->type.baseType == HLSLBaseType_RasterizerOrderedByteAddressBuffer) - { - bool isUsed = usedNames.HasString(buffer->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type(HLSLBaseType_Uint); - type.addressSpace = HLSLAddressSpace_Constant; - type.typeName = m_tree->AddStringFormatCached("uint"); - type.structuredTypeName = type.typeName; - - //int bufferRegister = ParseRegister(buffer->registerName, nextBufferRegister) + m_options.bufferRegisterOffset; - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - if (buffer->type.baseType == HLSLBaseType_RasterizerOrderedByteAddressBuffer) - { - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d), raster_order_group(%d)", bufferRegister, 0); - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName, true)); - } - else - { - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName, true)); - } - } - } - else if (buffer->type.baseType == HLSLBaseType_StructuredBuffer || buffer->type.baseType == HLSLBaseType_PureBuffer) - { - - bool isUsed = usedNames.HasString(buffer->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type(HLSLBaseType_UserDefined); - type.addressSpace = HLSLAddressSpace_Constant; - - if (buffer->type.elementType) - { - type.baseType = buffer->type.elementType; - type.elementType = buffer->type.elementType; - type.structuredTypeName = type.typeName = m_tree->AddStringFormatCached("%s", getElementTypeAsStr(m_stringLibrary,buffer->type)); - } - else - { - type.baseType = buffer->type.elementType; - type.elementType = buffer->type.elementType; - switch (buffer->type.elementType) - { - case HLSLBaseType_Float: - type.typeName = m_tree->AddStringFormatCached("float"); - break; - case HLSLBaseType_Float2: - type.typeName = m_tree->AddStringFormatCached("float2"); - break; - case HLSLBaseType_Float3: - type.typeName = m_tree->AddStringFormatCached("float3"); - break; - case HLSLBaseType_Float4: - type.typeName = m_tree->AddStringFormatCached("float4"); - break; - - case HLSLBaseType_Half: - type.typeName = m_tree->AddStringFormatCached("half"); - break; - case HLSLBaseType_Half2: - type.typeName = m_tree->AddStringFormatCached("half2"); - break; - case HLSLBaseType_Half3: - type.typeName = m_tree->AddStringFormatCached("half3"); - break; - case HLSLBaseType_Half4: - type.typeName = m_tree->AddStringFormatCached("half4"); - break; - - case HLSLBaseType_Min16Float: - type.typeName = m_tree->AddStringFormatCached("half"); - break; - case HLSLBaseType_Min16Float2: - type.typeName = m_tree->AddStringFormatCached("half2"); - break; - case HLSLBaseType_Min16Float3: - type.typeName = m_tree->AddStringFormatCached("half3"); - break; - case HLSLBaseType_Min16Float4: - type.typeName = m_tree->AddStringFormatCached("half4"); - break; - - case HLSLBaseType_Min10Float: - type.typeName = m_tree->AddStringFormatCached("half"); - break; - case HLSLBaseType_Min10Float2: - type.typeName = m_tree->AddStringFormatCached("half2"); - break; - case HLSLBaseType_Min10Float3: - type.typeName = m_tree->AddStringFormatCached("half3"); - break; - case HLSLBaseType_Min10Float4: - type.typeName = m_tree->AddStringFormatCached("half4"); - break; - - case HLSLBaseType_Bool: - type.typeName = m_tree->AddStringFormatCached("bool"); - break; - case HLSLBaseType_Bool2: - type.typeName = m_tree->AddStringFormatCached("bool2"); - break; - case HLSLBaseType_Bool3: - type.typeName = m_tree->AddStringFormatCached("bool3"); - break; - case HLSLBaseType_Bool4: - type.typeName = m_tree->AddStringFormatCached("bool4"); - break; - - case HLSLBaseType_Int: - type.typeName = m_tree->AddStringFormatCached("int"); - break; - case HLSLBaseType_Int2: - type.typeName = m_tree->AddStringFormatCached("int2"); - break; - case HLSLBaseType_Int3: - type.typeName = m_tree->AddStringFormatCached("int3"); - break; - case HLSLBaseType_Int4: - type.typeName = m_tree->AddStringFormatCached("int4"); - break; - - case HLSLBaseType_Uint: - type.typeName = m_tree->AddStringFormatCached("uint"); - break; - case HLSLBaseType_Uint2: - type.typeName = m_tree->AddStringFormatCached("uint2"); - break; - case HLSLBaseType_Uint3: - type.typeName = m_tree->AddStringFormatCached("uint3"); - break; - case HLSLBaseType_Uint4: - type.typeName = m_tree->AddStringFormatCached("uint4"); - break; - default: - break; - } - - type.structuredTypeName = type.typeName; - } - - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName, true)); - } - } - else if (buffer->type.baseType == HLSLBaseType_RWBuffer || buffer->type.baseType == HLSLBaseType_RasterizerOrderedBuffer) - { - bool isUsed = usedNames.HasString(buffer->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type(buffer->type.elementType); - type.addressSpace = HLSLAddressSpace_Device; - - - const char* atomic = ""; - - if (buffer->bAtomic) - atomic = "atomic_"; - - type.typeName = m_tree->AddStringFormatCached("%s%s", atomic, RawStr(GetTypeName(type))); - - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - if (buffer->type.baseType == HLSLBaseType_RWBuffer) - { - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName)); - } - else if (buffer->type.baseType == HLSLBaseType_RasterizerOrderedBuffer) - { - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d), raster_order_group(%d)", bufferRegister, 0); - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName)); - } - } - - m_RWBuffers.push_back(buffer); - } - else if (buffer->type.baseType == HLSLBaseType_RWStructuredBuffer || buffer->type.baseType == HLSLBaseType_RasterizerOrderedStructuredBuffer) - { - bool isUsed = usedNames.HasString(buffer->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type; - - if (buffer->type.elementType == HLSLBaseType_Unknown) - { - type.baseType = HLSLBaseType_UserDefined; - type.addressSpace = HLSLAddressSpace_Device; - type.typeName = m_tree->AddStringFormatCached("%s", getElementTypeAsStr(m_stringLibrary, buffer->type)); - } - else - { - type.addressSpace = HLSLAddressSpace_Device; - type.baseType = buffer->type.elementType; - type.elementType = buffer->type.elementType; - - const char* atomic = ""; - - if (buffer->bAtomic) - atomic = "atomic_"; - - switch (buffer->type.elementType) - { - case HLSLBaseType_Float: - type.typeName = m_tree->AddStringFormatCached("%sfloat", atomic); - break; - case HLSLBaseType_Float2: - type.typeName = m_tree->AddStringFormatCached("%sfloat2", atomic); - break; - case HLSLBaseType_Float3: - type.typeName = m_tree->AddStringFormatCached("%sfloat3", atomic); - break; - case HLSLBaseType_Float4: - type.typeName = m_tree->AddStringFormatCached("%sfloat4", atomic); - break; - - case HLSLBaseType_Half: - type.typeName = m_tree->AddStringFormatCached("%shalf", atomic); - break; - case HLSLBaseType_Half2: - type.typeName = m_tree->AddStringFormatCached("%shalf2", atomic); - break; - case HLSLBaseType_Half3: - type.typeName = m_tree->AddStringFormatCached("%shalf3", atomic); - break; - case HLSLBaseType_Half4: - type.typeName = m_tree->AddStringFormatCached("%shalf4", atomic); - break; - - case HLSLBaseType_Min16Float: - type.typeName = m_tree->AddStringFormatCached("%shalf", atomic); - break; - case HLSLBaseType_Min16Float2: - type.typeName = m_tree->AddStringFormatCached("%shalf2", atomic); - break; - case HLSLBaseType_Min16Float3: - type.typeName = m_tree->AddStringFormatCached("%shalf3", atomic); - break; - case HLSLBaseType_Min16Float4: - type.typeName = m_tree->AddStringFormatCached("%shalf4", atomic); - break; - - case HLSLBaseType_Min10Float: - type.typeName = m_tree->AddStringFormatCached("%shalf", atomic); - break; - case HLSLBaseType_Min10Float2: - type.typeName = m_tree->AddStringFormatCached("%shalf2", atomic); - break; - case HLSLBaseType_Min10Float3: - type.typeName = m_tree->AddStringFormatCached("%shalf3", atomic); - break; - case HLSLBaseType_Min10Float4: - type.typeName = m_tree->AddStringFormatCached("%shalf4", atomic); - break; - - case HLSLBaseType_Bool: - type.typeName = m_tree->AddStringFormatCached("%sbool", atomic); - break; - case HLSLBaseType_Bool2: - type.typeName = m_tree->AddStringFormatCached("%sbool2", atomic); - break; - case HLSLBaseType_Bool3: - type.typeName = m_tree->AddStringFormatCached("%sbool3", atomic); - break; - case HLSLBaseType_Bool4: - type.typeName = m_tree->AddStringFormatCached("%sbool4", atomic); - break; - case HLSLBaseType_Int: - type.typeName = m_tree->AddStringFormatCached("%sint", atomic); - break; - case HLSLBaseType_Int2: - type.typeName = m_tree->AddStringFormatCached("%sint2", atomic); - break; - case HLSLBaseType_Int3: - type.typeName = m_tree->AddStringFormatCached("%sint3", atomic); - break; - case HLSLBaseType_Int4: - type.typeName = m_tree->AddStringFormatCached("%sint4", atomic); - break; - case HLSLBaseType_Uint: - type.typeName = m_tree->AddStringFormatCached("%suint", atomic); - break; - case HLSLBaseType_Uint2: - type.typeName = m_tree->AddStringFormatCached("%suint2", atomic); - break; - case HLSLBaseType_Uint3: - type.typeName = m_tree->AddStringFormatCached("%suint3", atomic); - break; - case HLSLBaseType_Uint4: - type.typeName = m_tree->AddStringFormatCached("%suint4", atomic); - break; - default: - break; - } - } - - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - if (buffer->type.baseType == HLSLBaseType_RWStructuredBuffer) - { - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName, true)); - } - else if (buffer->type.baseType == HLSLBaseType_RasterizerOrderedStructuredBuffer) - { - CachedString bufferRegisterName = m_tree->AddStringFormatCached("buffer(%d), raster_order_group(%d)", bufferRegister, 0); - AddClassArgument(new ClassArgument(buffer->name, type, bufferRegisterName, true)); - } - - } - - m_RWStructuredBuffers.push_back(buffer); - } - } - else if (statement->nodeType == HLSLNodeType_TextureState) - { - HLSLTextureState* textureState = (HLSLTextureState *)statement; - - bool isUsed = usedNames.HasString(textureState->name.m_string); - if (keepUnused || isUsed) - { - if(textureState->type.baseType >= HLSLBaseType_Texture1D && - textureState->type.baseType <= HLSLBaseType_TextureCubeArray) - { - HLSLType type(HLSLBaseType_TextureState); - type.addressSpace = HLSLAddressSpace_Undefined; - type.baseType = textureState->type.baseType; - type.array = textureState->type.array; - type.arrayDimension = textureState->type.arrayDimension; - type.arrayExtent[0] = textureState->type.arrayExtent[0]; - type.arrayExtent[1] = textureState->type.arrayExtent[1]; - type.arrayExtent[2] = textureState->type.arrayExtent[2]; - - CachedString textureName; - CachedString textureRegisterName; - - if (type.array) - { - type.baseType = HLSLBaseType_UserDefined; - type.addressSpace = HLSLAddressSpace_Constant; - type.typeName = m_tree->AddStringFormatCached("Uniforms_%s", RawStr(textureState->name)); - - HLSLBuffer * buffer = m_tree->AddNode(NULL, 0); - buffer->field = m_tree->AddNode(NULL, 0); - - HLSLDeclaration * declaration = buffer->field; - - HLSLType fieldType(HLSLBaseType_TextureState); - fieldType.addressSpace = HLSLAddressSpace_Undefined; - fieldType.baseType = textureState->type.baseType; - fieldType.array = type.array; - fieldType.arrayDimension = type.arrayDimension; - fieldType.arrayExtent[0] = type.arrayExtent[0]; - fieldType.arrayExtent[1] = type.arrayExtent[1]; - fieldType.arrayExtent[2] = type.arrayExtent[2]; - declaration->name = textureState->name; - declaration->type = fieldType; - - buffer->field->name = m_tree->AddStringFormatCached("Textures"); - buffer->fileName = MakeCached("????"); - buffer->name = textureState->name; - - - HLSLStatement* prevStatement = statement; - prevStatement->hidden = true; - - HLSLStatement* prevsNextStatement = prevStatement->nextStatement; - prevStatement->nextStatement = buffer; - - buffer->nextStatement = prevsNextStatement; - statement = buffer; - - //int bufferRegister = nextBufferRegister + m_options.bufferRegisterOffset; - //nextBufferRegister++; - int bufferRegister = GetTextureRegister(buffer->name); - - textureName = m_tree->AddStringFormatCached("%s", RawStr(textureState->name)); - textureRegisterName = m_tree->AddStringFormatCached("buffer(%d)", bufferRegister); - AddClassArgument(new ClassArgument(textureName, type, textureRegisterName)); - } - else - { - //int textureRegister = nextTextureRegister + m_options.textureRegisterOffset; - //nextTextureRegister++; - int textureRegister = GetTextureRegister(textureState->name); - - textureName = m_tree->AddStringFormatCached("%s", RawStr(textureState->name)); - textureRegisterName = m_tree->AddStringFormatCached("texture(%d)", textureRegister); - AddClassArgument(new ClassArgument(textureName, type, textureRegisterName)); - } - } - else if (textureState->type.baseType >= HLSLBaseType_RasterizerOrderedTexture1D && - textureState->type.baseType <= HLSLBaseType_RasterizerOrderedTexture3D) - { - - HLSLType type(HLSLBaseType_RWTextureState); - type.addressSpace = HLSLAddressSpace_Undefined; - type.baseType = textureState->type.baseType; - type.array = textureState->type.array; - type.arrayDimension = textureState->type.arrayDimension; - type.arrayExtent[0] = textureState->type.arrayExtent[0]; - type.arrayExtent[1] = textureState->type.arrayExtent[1]; - type.arrayExtent[2] = textureState->type.arrayExtent[2]; - - //int textureRegister = nextTextureRegister + m_options.textureRegisterOffset; - //nextTextureRegister++; - int textureRegister = GetTextureRegister(textureState->name); - - CachedString textureName = m_tree->AddStringFormatCached("%s", RawStr(textureState->name)); - - CachedString textureRegisterName = m_tree->AddStringFormatCached("texture(%d), raster_order_group(%d)", textureRegister, 0); - AddClassArgument(new ClassArgument(textureName, type, textureRegisterName)); - } - - else if (textureState->type.baseType >= HLSLBaseType_RWTexture1D && - textureState->type.baseType <= HLSLBaseType_RWTexture3D) - { - - HLSLType type(HLSLBaseType_RWTextureState); - type.addressSpace = HLSLAddressSpace_Undefined; - type.baseType = textureState->type.baseType; - type.array = textureState->type.array; - type.arrayDimension = textureState->type.arrayDimension; - type.arrayExtent[0] = textureState->type.arrayExtent[0]; - type.arrayExtent[1] = textureState->type.arrayExtent[1]; - type.arrayExtent[2] = textureState->type.arrayExtent[2]; - - //int textureRegister = nextTextureRegister + m_options.textureRegisterOffset; - //nextTextureRegister++; - int textureRegister = GetTextureRegister(textureState->name); - CachedString textureName = m_tree->AddStringFormatCached("%s", RawStr(textureState->name)); - - CachedString textureRegisterName = m_tree->AddStringFormatCached("texture(%d)", textureRegister); - AddClassArgument(new ClassArgument(textureName, type, textureRegisterName)); - } - } - } - else if (statement->nodeType == HLSLNodeType_SamplerState) - { - HLSLSamplerState* samplerState = (HLSLSamplerState *)statement; - - bool isUsed = usedNames.HasString(samplerState->name.m_string); - if (keepUnused || isUsed) - { - HLSLType type(HLSLBaseType_SamplerState); - type.addressSpace = HLSLAddressSpace_Undefined; - - //int samplerRegister = nextSamplerRegister++; - int samplerRegister = GetSamplerRegister(samplerState->name); - - CachedString samplerName = m_tree->AddStringFormatCached("%s", RawStr(samplerState->name)); - - type.typeName = samplerName; - type.baseType = HLSLBaseType_SamplerState; - - type.array = samplerState->type.array; - type.arrayDimension = samplerState->type.arrayDimension; - type.arrayExtent[0] = samplerState->type.arrayExtent[0]; - type.arrayExtent[1] = samplerState->type.arrayExtent[1]; - type.arrayExtent[2] = samplerState->type.arrayExtent[2]; - - CachedString samplerRegisterName = m_tree->AddStringFormatCached("sampler(%d)", samplerRegister); - AddClassArgument(new ClassArgument(samplerName, type, samplerRegisterName)); - - } - else if (statement->nodeType == HLSLNodeType_Function) - { - HLSLFunction* function = static_cast(statement); - - if ((String_Equal(function->name, m_entryName)) && m_target == Target_HullShader) - { - m_entryName = function->name = m_tree->AddStringFormatCached("VS%s", function->name); - } - else if (secondaryEntryFunction && m_target == Target_HullShader) - { - //assumes every entry function has same name - if ((String_Equal(function->name, m_secondaryEntryName))) - { - m_secondaryEntryName = function->name = m_tree->AddStringFormatCached("HS%s", function->name); - } - } - } - } - - statement = statement->nextStatement; - } // @@ IC: instance_id parameter must be a function argument. If we find it inside a struct we must move it to the function arguments // and patch all the references to it! @@ -1473,20 +1024,6 @@ int MSLGenerator::GetSamplerRegister(const CachedString & name) return -1; } -void MSLGenerator::CleanPrepass() -{ - ClassArgument* currentArg = m_firstClassArgument; - while (currentArg != NULL) - { - ClassArgument* nextArg = currentArg->nextArg; - delete currentArg; - currentArg = nextArg; - } - delete currentArg; - m_firstClassArgument = NULL; - m_lastClassArgument = NULL; -} - static void WriteTextureIndexVariation(const eastl::string & funcName, HLSLBaseType texType, HLSLBaseType indexType) { ASSERT_PARSER(HLSLBaseType_Texture <= texType && texType <= HLSLBaseType_RWTexture3D); @@ -1821,8 +1358,6 @@ void MSLGenerator::PrependDeclarations() bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Target target, const char* entryName, const Options& options) { - m_firstClassArgument = NULL; - m_lastClassArgument = NULL; m_stringLibrary = stringLibrary; m_tree = tree; @@ -1886,10 +1421,6 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe PrependDeclarations(); - - - - // In MSL, uniforms are parameters for the entry point, not globals: // to limit code rewriting, we wrap the entire original shader into a class. // Uniforms are then passed to the constructor and copied to member variables. @@ -1916,146 +1447,142 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe shaderClassName = "Compute_Shader"; break; default: - shaderClassName = "???_Shader"; + shaderClassName = ""; break; } - m_writer.WriteLine(0, "struct %s", shaderClassName); - m_writer.WriteLine(0, "{"); - HLSLRoot* root = m_tree->GetRoot(); - OutputStatements(1, root->statement, NULL); + OutputShaderClass(shaderClassName); + OutputMain(tree, entryFunction, secondaryEntryFunction, shaderClassName); - // Generate constructor - m_writer.WriteLine(0, ""); + m_Args.clear(); + m_tree = NULL; - m_writer.WriteLine(1, "%s(", shaderClassName); - const ClassArgument* currentArg = m_firstClassArgument; + // Any final check goes here, but shouldn't be needed as the Metal compiler is solid - const ClassArgument* prevArg = NULL; + return !m_error; +} - bool bSkip = false; - bool bPreSkip = false; +CachedString MSLGenerator::GetBuiltInSemantic(const CachedString & semantic, HLSLArgumentModifier modifier, const CachedString & argument, const CachedString & field) +{ + /* + if (m_target == Target_VertexShader && modifier == HLSLArgumentModifier_In && (String_Equal(semantic, "SV_InstanceID") || String_Equal(semantic, "INSTANCE_ID"))) + { + return "instance_id"; + } + else if (m_target == Target_VertexShader && modifier == HLSLArgumentModifier_In && (String_Equal(semantic, "SV_VertexID") || String_Equal(semantic, "VERTEX_ID"))) + { + return "vertex_id"; + } + else + */ + if (m_target == Target_FragmentShader && modifier == HLSLArgumentModifier_In && (String_Equal(semantic, "SV_POSITION") || String_Equal(semantic, "SV_Position"))) + { + CachedString newArgument = m_tree->AddStringFormatCached("float4(%s.%s.xyz, 1.0 / %s.%s.w)", RawStr(argument), RawStr(field), RawStr(argument), RawStr(field)); + return newArgument; + } + return CachedString(); +} - while (currentArg != NULL) +void MSLGenerator::OutputDeclaration(const char* prefix, HLSLDeclaration* decl, bool use_ref, bool outputId) +{ + if (decl->type.baseType == HLSLBaseType_UserDefined || decl->type.baseType == HLSLBaseType_OutputPatch) { - if (currentArg->type.addressSpace == HLSLAddressSpace_Constant) - m_writer.Write(0, "constant "); - else if (currentArg->type.addressSpace == HLSLAddressSpace_Device) - m_writer.Write(0, "device "); - - if (currentArg->type.baseType == HLSLBaseType_UserDefined) - { - if (currentArg->bStructuredBuffer) - m_writer.Write("%s* %s", RawStr(currentArg->type.typeName), RawStr(currentArg->name)); - else - m_writer.Write("%s & %s", RawStr(currentArg->type.typeName), RawStr(currentArg->name)); - } - else if (currentArg->type.baseType >= HLSLBaseType_FirstNumeric && currentArg->type.baseType <= HLSLBaseType_LastNumeric) - { - if (currentArg->bStructuredBuffer) - m_writer.Write("%s* %s", RawStr(currentArg->type.typeName), RawStr(currentArg->name)); - else - m_writer.Write("%s & %s", RawStr(currentArg->type.typeName), RawStr(currentArg->name)); - } - else if (currentArg->type.baseType >= HLSLBaseType_Texture1D && currentArg->type.baseType <= HLSLBaseType_TextureCubeArray) + m_writer.Write("%s%s& %s", CHECK_CSTR(prefix), RawStr(decl->type.typeName), RawStr(decl->name)); + } + else if (decl->type.baseType == HLSLBaseType_CBuffer || decl->type.baseType == HLSLBaseType_ConstantBuffer || decl->type.baseType == HLSLBaseType_TBuffer) + { + m_writer.Write("constant %sUniforms_%s& %s", CHECK_CSTR(prefix), RawStr(decl->name), RawStr(decl->name)); + } + else if (IsBuffer(decl->type.baseType)) + { + m_writer.Write("%s %s%s* %s", IsRWBuffer(decl->type.baseType) ? "device" : "constant", IsStructuredBuffer(decl->type.baseType) ? prefix : "", RawStr(decl->type.typeName), RawStr(decl->name)); + } + else if (IsTextureType(decl->type.baseType)) + { + if (decl->type.array) { - if (currentArg->type.typeName.IsEmpty()) - { - if (currentArg->type.array) - { - m_writer.Write(0, "array<%s, %d> %s", RawStr(GetTypeName(currentArg->type)), currentArg->type.arrayExtent[0] == 0 ? DEFAULT_TEXTURE_COUNT : currentArg->type.arrayExtent[0], RawStr(currentArg->name)); - } - else - m_writer.Write(0, "%s %s", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name)); - } - else - m_writer.Write(0, "constant %s::%s & %s", CHECK_CSTR(shaderClassName), RawStr(currentArg->type.typeName), RawStr(currentArg->name)); - } - else if (currentArg->type.baseType >= HLSLBaseType_RWTexture1D && currentArg->type.baseType <= HLSLBaseType_RWTexture3D) - { - if (currentArg->type.typeName.IsEmpty()) - { - if (currentArg->type.array) - { - m_writer.Write(0, "array<%s, %d> %s", RawStr(GetTypeName(currentArg->type)), currentArg->type.arrayExtent[0] == 0 ? DEFAULT_TEXTURE_COUNT : currentArg->type.arrayExtent[0], RawStr(currentArg->name)); - } - else - m_writer.Write(0, "%s %s", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name)); - } - else - m_writer.Write(0, "constant %s::%s & %s", CHECK_CSTR(shaderClassName), RawStr(currentArg->type.typeName), RawStr(currentArg->name)); - } - else if (currentArg->type.baseType == HLSLBaseType_SamplerState || currentArg->type.baseType == HLSLBaseType_SamplerComparisonState ||currentArg->type.baseType == HLSLBaseType_Sampler) - { - if (currentArg->type.array) - m_writer.Write(0, "array_ref %s", RawStr(currentArg->name)); - else - m_writer.Write(0, "%s %s", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name)); + //if (use_ref) + // m_writer.Write("array_ref<%s> %s", RawStr(GetTypeName(decl->type)), RawStr(decl->name)); + //else + m_writer.Write("array<%s, %d> %s", RawStr(GetTypeName(decl->type)), decl->type.arrayExtent[0] == 0 ? DEFAULT_TEXTURE_COUNT : decl->type.arrayExtent[0], RawStr(decl->name)); } else + m_writer.Write("%s %s", RawStr(GetTypeName(decl->type)), RawStr(decl->name)); + } + else if (decl->type.baseType == HLSLBaseType_SamplerState || decl->type.baseType == HLSLBaseType_SamplerComparisonState || decl->type.baseType == HLSLBaseType_Sampler) + { + if (decl->type.array) { - m_writer.Write(0, "%s %s", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name)); + m_writer.Write("array %s", decl->type.arrayExtent[0], RawStr(decl->name)); } + else + m_writer.Write("%s %s", RawStr(GetTypeName(decl->type)), RawStr(decl->name)); + } - bPreSkip = bSkip; + else + { + m_writer.Write("%s %s", RawStr(GetTypeName(decl->type)), RawStr(decl->name)); + } - prevArg = currentArg; - currentArg = currentArg->nextArg; + if (outputId && decl->registerIndex >= 0) + { + m_writer.Write(" [[id(%d)]]", decl->registerIndex); + } +} - const ClassArgument* traversalArg = currentArg; +void MSLGenerator::OutputShaderClass(const char* shaderClassName) +{ + m_writer.WriteLine(0, "struct %s", shaderClassName); + m_writer.WriteLine(0, "{"); + HLSLRoot* root = m_tree->GetRoot(); + OutputStatements(1, root->statement); - while (traversalArg) - { - { - m_writer.Write(","); - break; - } + // Generate constructor + m_writer.WriteLine(0, ""); - traversalArg = traversalArg->nextArg; + m_writer.BeginLine(1); + m_writer.Write("%s(", shaderClassName); + + size_t argCount = m_Args.size(); + for (size_t i=0; i 0) + { + m_writer.Write(", "); } - + OutputDeclaration("", decl, true, false); } - m_writer.Write(")"); - - bSkip = false; - bPreSkip = false; + m_writer.EndLine(argCount ? ") :" : ")"); - currentArg = m_firstClassArgument; - if (currentArg) m_writer.Write(" :\n"); - while (currentArg != NULL) + + if (argCount) { - bPreSkip = bSkip; + m_writer.BeginLine(2); + for (size_t i=0; iname), RawStr(currentArg->name)); - - prevArg = currentArg; - currentArg = currentArg->nextArg; - - const ClassArgument* traversalArg = currentArg; - - while (traversalArg) - { - { - m_writer.Write(","); - break; - } - - traversalArg = traversalArg->nextArg; - } + HLSLDeclaration* decl = m_Args[i]; + m_writer.Write("%s%s(%s)", (i > 0) ? ", " : "", RawStr(decl->name), RawStr(decl->name)); } - + m_writer.EndLine(""); } - m_writer.EndLine(" {}"); - m_writer.WriteLine(0, "};"); // Class - // Generate real entry point, the one called by Metal - m_writer.WriteLine(0, ""); + m_writer.WriteLine(1, "{}\n};"); // Class +} + +void MSLGenerator::OutputMain(HLSLTree* tree, HLSLFunction* entryFunction, HLSLFunction* secondaryEntryFunction, const char* shaderClassName) +{ + const char* entryName = RawStr(entryFunction->name); + // Generate real entry point, the one called by Metal // create a separate struct for the different versions - eastl::vector < HLSLArgument * > stageParams; - eastl::vector < HLSLArgument * > resParams; + eastl::vector stageParams; + eastl::vector resParams; + + eastl::string typePrefix; + typePrefix.sprintf("%s::", shaderClassName); // mainParams are the ones we will actually use in the main function, the extraParams // are the ones we are packing into a special little structure @@ -2107,6 +1634,7 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe } else { + // TODO: should not happen, as all main arguments require semantic resParams.push_back(argument); } } @@ -2228,10 +1756,56 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe m_writer.WriteLine(0, "};"); } + eastl::vector sortedArgs; + size_t argStart = 0; + size_t argCount = m_Args.size(); + + if (m_options.useArgBufs && argStart < argCount) + { + sortedArgs = m_Args; + for (HLSLDeclaration* decl: sortedArgs) + { + HLSLBuffer* buffer = static_cast(decl); + if (decl->nodeType != HLSLNodeType_Buffer || !buffer->bPushConstant) + { + decl->registerSpace = decl->registerSpace == -1 ? 0/*default space*/ : decl->registerSpace; + } + } + + AssignRegisters(m_tree->GetRoot(), m_options.shiftVec); + + eastl::stable_sort( + sortedArgs.begin(), + sortedArgs.end(), + [](const HLSLDeclaration* lhs, const HLSLDeclaration* rhs){ + return (lhs->registerSpace != rhs->registerSpace) ? (lhs->registerSpace < rhs->registerSpace) : (lhs->registerIndex < rhs->registerIndex); + } + ); + + argStart = eastl::distance(sortedArgs.begin(), eastl::lower_bound(sortedArgs.begin(), sortedArgs.end(), 0, [](HLSLDeclaration* d, int v){return d->registerSpace < v;})); + + int space = INT32_MIN; + for (size_t i = argStart; i < argCount; ++i) + { + HLSLDeclaration* decl = sortedArgs[i]; + if (space != decl->registerSpace) + { + m_writer.Write("%sstruct ArgBuffer%d\n{\n", space == INT32_MIN ? "" : "};\n\n", decl->registerSpace); + space = decl->registerSpace; + } + + m_writer.BeginLine(1); + OutputDeclaration(typePrefix.c_str(), decl, false, true); + m_writer.EndLine(";"); + } + if (argStart < argCount) + m_writer.Write("};\n"); + } //print Attributes for main Func m_writer.BeginLine(0); + HLSLRoot* root = m_tree->GetRoot(); HLSLStatement* _statement = root->statement; while (_statement) @@ -2288,7 +1862,6 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe m_writer.Write("fragment "); } - // Return type. if (wrapReturnType) { @@ -2329,202 +1902,104 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe m_writer.Write(" stageMain(\n"); - //int argumentCount = 0; - - bool bFirstStruct = false; - //CachedString firstTypeName; - - int numWritten = 0; + size_t numWritten = 0; if (stageParams.size() >= 1) { m_writer.Write("\t%s_input inputData [[stage_in]]", entryName); + numWritten = 1; } for (int i = 0; i < resParams.size(); i++) { HLSLArgument * argument = resParams[i]; - if (!argument->hidden) - { - if (numWritten >= 1) - { - m_writer.Write(",\n"); - } - - if (argument->type.baseType == HLSLBaseType_UserDefined || argument->type.baseType == HLSLBaseType_OutputPatch) - { - if (m_target == Target_HullShader) - m_writer.Write(1,"constant %s::", CHECK_CSTR(shaderClassName)); - else - m_writer.Write(1, "%s::", CHECK_CSTR(shaderClassName)); - } - - if (m_target == Target_HullShader) - m_writer.Write("%s* %s", RawStr(GetTypeName(argument->type)), RawStr(argument->name)); - else - { - m_writer.Write("%s %s", RawStr(GetTypeName(argument->type)), RawStr(argument->name)); - } - - if (argument->type.baseType == HLSLBaseType_UserDefined || argument->type.baseType == HLSLBaseType_OutputPatch) - { - if (m_target == Target_HullShader) - m_writer.Write(" [[buffer(0)]]"); // not sure about this - else - m_writer.Write(" [[stage_in]]"); - - } - else if (argument->sv_semantic.IsNotEmpty()) - { - m_writer.Write(" [[%s]]", RawStr(argument->sv_semantic)); - } - -#if 0 - // @@ IC: We are assuming that the first argument (x) -> first struct (o) is the 'stage_in'. - // this really doesn't seem robust, disabling for now, enabling it later if we need to - if (bFirstStruct == false && argument->type.baseType == HLSLBaseType_UserDefined || argument->type.baseType == HLSLBaseType_OutputPatch) - { - bFirstStruct = true; - firstTypeName = argument->type.typeName; - - if (m_target == Target_HullShader) - m_writer.Write(" [[buffer(0)]]"); - else - m_writer.Write(" [[stage_in]]"); - - } - else if (argument->sv_semantic.IsNotEmpty()) - { - m_writer.Write(" [[%s]]", RawStr(argument->sv_semantic)); - } -#endif - } - else + if (argument->hidden) { continue; } - numWritten++; - } - - currentArg = m_firstClassArgument; - - prevArg = NULL; - - bSkip = false; - bPreSkip = false; - - bool bIntent = false; - - while (currentArg != NULL) - { - ClassArgument* nextArg = currentArg->nextArg; - - if (nextArg) + if (numWritten >= 1) { - if (!bSkip) - m_writer.Write(",\n"); - } - else if(nextArg) - { - if (!bSkip) - m_writer.Write(",\n"); - } - else if (nextArg == NULL) - { - if (!bSkip) - m_writer.Write(",\n"); + m_writer.Write(",\n"); } - - bPreSkip = bSkip; - - bIntent = false; - - if (currentArg->type.addressSpace == HLSLAddressSpace_Constant) + if (argument->type.baseType == HLSLBaseType_UserDefined || argument->type.baseType == HLSLBaseType_OutputPatch) { - m_writer.Write(1, "constant "); - bIntent = true; + if (m_target == Target_HullShader) + m_writer.Write(1,"constant %s::", CHECK_CSTR(shaderClassName)); + else + m_writer.Write(1, "%s::", CHECK_CSTR(shaderClassName)); } - else if (currentArg->type.addressSpace == HLSLAddressSpace_Device) + + if (m_target == Target_HullShader) + m_writer.Write(1, "%s* %s", RawStr(GetTypeName(argument->type)), RawStr(argument->name)); + else { - m_writer.Write(1, "device "); - bIntent = true; + m_writer.Write(1, "%s %s", RawStr(GetTypeName(argument->type)), RawStr(argument->name)); } - if (currentArg->type.baseType == HLSLBaseType_UserDefined || currentArg->type.baseType == HLSLBaseType_OutputPatch) + if (argument->type.baseType == HLSLBaseType_UserDefined || argument->type.baseType == HLSLBaseType_OutputPatch) { - if (currentArg->bStructuredBuffer) - m_writer.Write(bIntent ? 0 : 1, "%s::%s* %s [[%s]]", CHECK_CSTR(shaderClassName), RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); + if (m_target == Target_HullShader) + m_writer.Write(" [[buffer(0)]]"); // not sure about this else - m_writer.Write(bIntent ? 0 : 1, "%s::%s & %s [[%s]]", CHECK_CSTR(shaderClassName), RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); + m_writer.Write(" [[stage_in]]"); } - else if (currentArg->type.baseType >= HLSLBaseType_FirstNumeric && currentArg->type.baseType <= HLSLBaseType_LastNumeric) + else if (argument->sv_semantic.IsNotEmpty()) { - if (currentArg->bStructuredBuffer) - m_writer.Write("%s* %s [[%s]]", RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); - else - m_writer.Write("%s & %s [[%s]]", RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); + m_writer.Write(" [[%s]]", RawStr(argument->sv_semantic)); } - else if (currentArg->type.baseType >= HLSLBaseType_Texture1D && currentArg->type.baseType <= HLSLBaseType_TextureCubeArray) + + numWritten++; + } + + if (m_options.useArgBufs) + { + int space = INT32_MIN; + for (size_t i = argStart; i < argCount; ++i) { - if (currentArg->type.typeName.IsEmpty()) - { - if (currentArg->type.array) - m_writer.Write(bIntent ? 0 : 1, "array<%s, %d> %s [[%s]]", RawStr(GetTypeName(currentArg->type)), currentArg->type.arrayExtent[0] == 0 ? DEFAULT_TEXTURE_COUNT : currentArg->type.arrayExtent[0], RawStr(currentArg->name), RawStr(currentArg->registerName)); - else - m_writer.Write(bIntent ? 0 : 1, "%s %s [[%s]]", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name), RawStr(currentArg->registerName)); - } - else + HLSLDeclaration* decl = sortedArgs[i]; + if (space != decl->registerSpace) { - if (currentArg->type.baseType == HLSLBaseType_UserDefined) - { - m_writer.Write(bIntent ? 0 : 1, "constant %s::%s & %s [[%s]]", CHECK_CSTR(shaderClassName), RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); - } - else + if (numWritten >= 1) { - m_writer.Write(bIntent ? 0 : 1, "constant %s & %s [[%s]]", RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); + m_writer.Write(",\n"); } + space = decl->registerSpace; + m_writer.Write(1, "constant ArgBuffer%d& argBuffer%d [[buffer(%d)]]", space, space, space); } } - else if (currentArg->type.baseType >= HLSLBaseType_RWTexture1D && currentArg->type.baseType <= HLSLBaseType_RWTexture3D) + numWritten += argCount - argStart; + for (size_t i = 0; i < argStart; ++i) { - if (currentArg->type.typeName.IsEmpty()) + if (numWritten >= 1) { - if (currentArg->type.array) - { - m_writer.Write(bIntent ? 0 : 1, "array<%s, %d> %s [[%s]]", RawStr(GetTypeName(currentArg->type)), currentArg->type.arrayExtent[0] == 0 ? DEFAULT_TEXTURE_COUNT : currentArg->type.arrayExtent[0], RawStr(currentArg->name), RawStr(currentArg->registerName)); - } - else - m_writer.Write(bIntent ? 0 : 1, "%s %s [[%s]]", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name), RawStr(currentArg->registerName)); + m_writer.Write(",\n"); } - else - m_writer.Write(bIntent ? 0 : 1, "constant %s::%s & %s [[%s]]", CHECK_CSTR(shaderClassName), RawStr(currentArg->type.typeName), RawStr(currentArg->name), RawStr(currentArg->registerName)); + HLSLDeclaration* decl = sortedArgs[i]; + m_writer.Write(1, ""); + OutputDeclaration(typePrefix.c_str(), decl, false, false); } - else if (currentArg->type.baseType == HLSLBaseType_SamplerState || currentArg->type.baseType == HLSLBaseType_SamplerComparisonState || currentArg->type.baseType == HLSLBaseType_Sampler) + numWritten += argStart; + } + else + { + for (size_t i=0; itype.array) + HLSLDeclaration* decl = m_Args[i]; + if (numWritten >= 1) { - m_writer.Write(bIntent ? 0 : 1, "array %s [[%s]]", currentArg->type.arrayExtent[0], RawStr(currentArg->name), RawStr(currentArg->registerName)); - } - else - m_writer.Write(bIntent ? 0 : 1, "%s %s [[%s]]", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name), RawStr(currentArg->registerName)); - } - else - { - m_writer.Write(1, "%s %s [[%s]]", RawStr(GetTypeName(currentArg->type)), RawStr(currentArg->name), RawStr(currentArg->registerName)); - } - - prevArg = currentArg; - currentArg = currentArg->nextArg; + m_writer.Write(",\n"); + } + m_writer.Write(1, ""); + OutputDeclaration(typePrefix.c_str(), decl, false, false); - + ++numWritten; + } } - - if (m_target == Target_HullShader) { //need to add additional arguments (PatchTess, Hullshader Output, threadId) @@ -2565,20 +2040,13 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe for (int i = 0; i < resParams.size(); i++) { HLSLArgument * argument = resParams[i]; - m_writer.BeginLine(1); if (argument->hidden) { continue; } - /* - if (firstTypeName == argument->type.typeName && m_target == Target_HullShader) - { - continue; - } - */ - + m_writer.BeginLine(1); // I guess we'll say that all user defined types need this? if (argument->type.baseType == HLSLBaseType_UserDefined) { @@ -2587,7 +2055,6 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe CachedString newArgumentName = m_tree->AddStringFormatCached("%s0", RawStr(argument->name)); - if (argument->type.baseType == HLSLBaseType_OutputPatch) { } @@ -2687,8 +2154,6 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe } } } - - //argument = argument->nextArgument; } } @@ -2746,67 +2211,36 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe } } - bSkip = false; - bPreSkip = false; - // Create the helper class instance and call the entry point from the original shader m_writer.BeginLine(1); m_writer.Write("%s %s", CHECK_CSTR(shaderClassName), CHECK_CSTR(entryName)); - - currentArg = m_firstClassArgument; - - int arg_counter = 0; - if (currentArg) + if (!m_Args.empty()) { - m_writer.Write("(\n"); - - prevArg = NULL; - - while (currentArg != NULL) + m_writer.Write("("); + if (m_options.useArgBufs) { - ClassArgument* nextArg = currentArg->nextArg; - - if (nextArg) - { - if (!bSkip && (m_firstClassArgument != currentArg)) - m_writer.Write(",\n"); - } - else if (nextArg) + for (size_t i=0; i(decl); + if (decl->nodeType != HLSLNodeType_Buffer || !buffer->bPushConstant) + m_writer.Write("%sargBuffer%d.%s", (i > 0) ? ", " : "", decl->registerSpace, decl->name); + else + m_writer.Write("%s%s", (i > 0) ? ", " : "", RawStr(decl->name)); } - - bPreSkip = bSkip; - - bIntent = false; - - + } + else + { + for (size_t i=0; iname)); + m_writer.Write("%s%s", (i > 0) ? ", " : "", RawStr(m_Args[i]->name)); } - - prevArg = currentArg; - currentArg = currentArg->nextArg; - } - m_writer.Write(")"); } - m_writer.EndLine(";"); - - - if (m_target == Target_HullShader) { m_writer.BeginLine(2); @@ -2983,23 +2417,21 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe { HLSLArgument * argument = argumentVec[i]; - if (!argument->hidden) + if (argument->hidden) { - if (numWritten >= 1) - { - m_writer.Write(", "); - } - CachedString newArgumentName = m_tree->AddStringFormatCached("%s0", RawStr(argument->name)); - - if (argument->type.baseType == HLSLBaseType_OutputPatch || m_target == Target_HullShader) - m_writer.Write("%s", RawStr(argument->name)); - else - m_writer.Write("%s", RawStr(newArgumentName)); + continue; } - else + + if (numWritten >= 1) { - continue; + m_writer.Write(", "); } + CachedString newArgumentName = m_tree->AddStringFormatCached("%s0", RawStr(argument->name)); + + if (argument->type.baseType == HLSLBaseType_OutputPatch || m_target == Target_HullShader) + m_writer.Write("%s", RawStr(argument->name)); + else + m_writer.Write("%s", RawStr(newArgumentName)); numWritten++; } @@ -3045,37 +2477,6 @@ bool MSLGenerator::Generate(StringLibrary * stringLibrary, HLSLTree* tree, Targe } m_writer.WriteLine(0, "}"); - - - - CleanPrepass(); - m_tree = NULL; - - // Any final check goes here, but shouldn't be needed as the Metal compiler is solid - - return !m_error; -} - -CachedString MSLGenerator::GetBuiltInSemantic(const CachedString & semantic, HLSLArgumentModifier modifier, const CachedString & argument, const CachedString & field) -{ - /* - if (m_target == Target_VertexShader && modifier == HLSLArgumentModifier_In && (String_Equal(semantic, "SV_InstanceID") || String_Equal(semantic, "INSTANCE_ID"))) - { - return "instance_id"; - } - else if (m_target == Target_VertexShader && modifier == HLSLArgumentModifier_In && (String_Equal(semantic, "SV_VertexID") || String_Equal(semantic, "VERTEX_ID"))) - { - return "vertex_id"; - } - else - */ - if (m_target == Target_FragmentShader && modifier == HLSLArgumentModifier_In && (String_Equal(semantic, "SV_POSITION") || String_Equal(semantic, "SV_Position"))) - { - CachedString newArgument = m_tree->AddStringFormatCached("float4(%s.%s.xyz, 1.0 / %s.%s.w)", RawStr(argument), RawStr(field), RawStr(argument), RawStr(field)); - return newArgument; - } - - return CachedString(); } CachedString MSLGenerator::MakeCached(const char * str) @@ -3089,7 +2490,7 @@ const char* MSLGenerator::GetResult() const return m_writer.GetResult(); } -void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const HLSLFunction* function) +void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement) { // Main generator loop: called recursively while (statement != NULL) @@ -3106,90 +2507,16 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const { HLSLDeclaration* declaration = static_cast(statement); m_writer.BeginLine(indent, RawStr(declaration->fileName), declaration->line); - OutputDeclaration(declaration, function); + OutputDeclaration(declaration); m_writer.EndLine(";"); } else if (statement->nodeType == HLSLNodeType_TextureState) { HLSLTextureState* textureState = static_cast(statement); - - if (textureState->type.baseType >= HLSLBaseType_Texture1D && - textureState->type.baseType <= HLSLBaseType_TextureCubeArray) - { - HLSLType type; - type.baseType = textureState->type.baseType; - - - if (textureState->type.array) - { - m_writer.WriteLine(indent, "array<%s, %d> %s;", RawStr(GetTypeName(type)), textureState->type.arrayExtent[0] == 0 ? DEFAULT_TEXTURE_COUNT : textureState->type.arrayExtent[0], RawStr(textureState->name)); - } - else - { - m_writer.BeginLine(indent, RawStr(textureState->fileName), textureState->line); - - m_writer.Write("%s", RawStr(GetTypeName(type))); - m_writer.Write(" %s", RawStr(textureState->name)); - - m_writer.EndLine(";"); - } - } - else if (textureState->type.baseType >= HLSLBaseType_RasterizerOrderedTexture1D && - textureState->type.baseType <= HLSLBaseType_RasterizerOrderedTexture3D) - { - HLSLType type; - type.baseType = textureState->type.baseType; - - if (textureState->type.array) - { - //multiple Array??????????? - m_writer.WriteLine(indent, "struct %sData", RawStr(textureState->name)); - m_writer.WriteLine(indent, "{"); - - for (int i = 0; i < (int)textureState->type.arrayDimension; i++) - { - m_writer.WriteLine(indent + 1, "array<%s, %d> textures;", RawStr(GetTypeName(type)), textureState->type.arrayExtent[i]); - } - m_writer.WriteLine(indent, "}"); - } - else - { - m_writer.BeginLine(indent, RawStr(textureState->fileName), textureState->line); - - m_writer.Write("%s", RawStr(GetTypeName(type))); - m_writer.Write(" %s", RawStr(textureState->name)); - - m_writer.EndLine(";"); - } - } - else if (textureState->type.baseType >= HLSLBaseType_RWTexture1D && - textureState->type.baseType <= HLSLBaseType_RWTexture3D) - { - HLSLType type; - type.baseType = textureState->type.baseType; - - if (textureState->type.array) - { - //multiple Array??????????? - m_writer.WriteLine(indent, "struct %sData", RawStr(textureState->name)); - m_writer.WriteLine(indent, "{"); - - for (int i = 0; i < (int)textureState->type.arrayDimension; i++) - { - m_writer.WriteLine(indent + 1, "array<%s, %d> textures;", RawStr(GetTypeName(type)), textureState->type.arrayExtent[i]); - } - m_writer.WriteLine(indent, "}"); - } - else - { - m_writer.BeginLine(indent, RawStr(textureState->fileName), textureState->line); - - m_writer.Write("%s", RawStr(GetTypeName(type))); - m_writer.Write(" %s", RawStr(textureState->name)); - - m_writer.EndLine(";"); - } - } + m_Args.push_back(textureState); + m_writer.BeginLine(1); + OutputDeclaration("", textureState, true, false); + m_writer.EndLine(";"); } //Does Metal support groupshared memory???? else if (statement->nodeType == HLSLNodeType_GroupShared) @@ -3197,13 +2524,14 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const HLSLGroupShared* pGroupShared = static_cast(statement); //m_writer.Write(0, "shared "); - OutputDeclaration(pGroupShared->declaration, function); + OutputDeclaration(pGroupShared->declaration); m_writer.EndLine(";"); } else if (statement->nodeType == HLSLNodeType_SamplerState) { HLSLSamplerState* samplerState = static_cast(statement); + m_Args.push_back(samplerState); m_writer.BeginLine(indent, RawStr(samplerState->fileName), samplerState->line); @@ -3218,7 +2546,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const // m_writer.Write("["); - // OutputExpression(samplerState->type.arraySize, NULL, NULL, function, false); + // OutputExpression(samplerState->type.arraySize, NULL, NULL, false); // m_writer.Write("]"); @@ -3232,6 +2560,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const else if (statement->nodeType == HLSLNodeType_Buffer) { HLSLBuffer* buffer = static_cast(statement); + m_Args.push_back(buffer); if (buffer->type.baseType == HLSLBaseType_CBuffer || buffer->type.baseType == HLSLBaseType_TBuffer || buffer->type.baseType == HLSLBaseType_ConstantBuffer) { @@ -3496,7 +2825,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const { m_writer.BeginLine(indent, RawStr(statement->fileName), statement->line); - OutputExpression(expressionStatement->expression, NULL, NULL, function, true); + OutputExpression(expressionStatement->expression, NULL, NULL, true); m_writer.EndLine(";"); } } @@ -3506,7 +2835,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const if (returnStatement->expression != NULL) { m_writer.Write(indent, "return "); - OutputExpression(returnStatement->expression, NULL, NULL, function, true); + OutputExpression(returnStatement->expression, NULL, NULL, true); m_writer.EndLine(";"); } else @@ -3534,7 +2863,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const HLSLIfStatement* ifStatement = static_cast(statement); m_writer.BeginLine(indent, RawStr(ifStatement->fileName), ifStatement->line); m_writer.Write("if ("); - OutputExpression(ifStatement->condition, NULL, NULL, function, true); + OutputExpression(ifStatement->condition, NULL, NULL, false); m_writer.Write(")"); m_writer.EndLine(); @@ -3543,7 +2872,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const { { m_writer.WriteLine(indent, "{"); - OutputStatements(indent + 1, ifStatement->statement, function); + OutputStatements(indent + 1, ifStatement->statement); m_writer.WriteLine(indent, "}"); } } @@ -3555,11 +2884,11 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const for (int i = 0; i< ifStatement->elseifStatement.size(); i++) { m_writer.Write(indent, "else if ("); - OutputExpression(ifStatement->elseifStatement[i]->condition, NULL, NULL, function, true); + OutputExpression(ifStatement->elseifStatement[i]->condition, NULL, NULL, true); m_writer.Write(")"); m_writer.EndLine(); m_writer.WriteLine(indent, "{"); - OutputStatements(indent + 1, ifStatement->elseifStatement[i]->statement, function); + OutputStatements(indent + 1, ifStatement->elseifStatement[i]->statement); m_writer.WriteLine(indent, "}"); } @@ -3567,7 +2896,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const { m_writer.WriteLine(indent, "else"); m_writer.WriteLine(indent, "{"); - OutputStatements(indent + 1, ifStatement->elseStatement, function); + OutputStatements(indent + 1, ifStatement->elseStatement); m_writer.WriteLine(indent, "}"); } } @@ -3576,7 +2905,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const HLSLSwitchStatement* switchStatement = static_cast(statement); m_writer.Write(indent, "switch ("); - OutputExpression(switchStatement->condition, NULL, NULL, function, false); + OutputExpression(switchStatement->condition, NULL, NULL, false); m_writer.Write(")\n"); m_writer.WriteLine(indent, "{"); @@ -3590,12 +2919,12 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const m_writer.Write(indent + 1, "case "); - OutputExpression(switchStatement->caseNumber[i], NULL, NULL, function, false); + OutputExpression(switchStatement->caseNumber[i], NULL, NULL, false); m_writer.Write(":\n"); m_writer.WriteLine(indent + 1, "{"); - OutputStatements(indent + 2, switchStatement->caseStatement[i], function); + OutputStatements(indent + 2, switchStatement->caseStatement[i]); m_writer.WriteLine(indent + 1, "}"); } @@ -3603,7 +2932,7 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const m_writer.Write(indent + 1, "default:\n"); m_writer.WriteLine(indent + 1, "{"); - OutputStatements(indent + 2, switchStatement->caseDefault, function); + OutputStatements(indent + 2, switchStatement->caseDefault); m_writer.WriteLine(indent + 1, "}"); m_writer.WriteLine(indent, "}"); @@ -3615,21 +2944,21 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const m_writer.Write("for ("); if (forStatement->initialization) - OutputDeclaration(forStatement->initialization, function); + OutputDeclaration(forStatement->initialization); else if (forStatement->initializationWithoutDeclaration) - OutputExpression(forStatement->initializationWithoutDeclaration, NULL, NULL, function, true); + OutputExpression(forStatement->initializationWithoutDeclaration, NULL, NULL, true); m_writer.Write("; "); - OutputExpression(forStatement->condition, NULL, NULL, function, true); + OutputExpression(forStatement->condition, NULL, NULL, true); m_writer.Write("; "); - OutputExpression(forStatement->increment, NULL, NULL, function, true); + OutputExpression(forStatement->increment, NULL, NULL, true); m_writer.Write(")"); m_writer.EndLine(); m_writer.WriteLine(indent, "{"); - OutputStatements(indent + 1, forStatement->statement, function); + OutputStatements(indent + 1, forStatement->statement); m_writer.WriteLine(indent, "}"); } else if (statement->nodeType == HLSLNodeType_WhileStatement) @@ -3639,17 +2968,17 @@ void MSLGenerator::OutputStatements(int indent, HLSLStatement* statement, const m_writer.BeginLine(indent, RawStr(whileStatement->fileName), whileStatement->line); m_writer.Write("while ("); - OutputExpression(whileStatement->condition, NULL, NULL, function, true); + OutputExpression(whileStatement->condition, NULL, NULL, true); m_writer.Write(") {"); m_writer.EndLine(); - OutputStatements(indent + 1, whileStatement->statement, function); + OutputStatements(indent + 1, whileStatement->statement); m_writer.WriteLine(indent, "}"); } else if (statement->nodeType == HLSLNodeType_BlockStatement) { HLSLBlockStatement* blockStatement = static_cast(statement); m_writer.WriteLineTagged(indent, RawStr(blockStatement->fileName), blockStatement->line, "{"); - OutputStatements(indent + 1, blockStatement->statement, function); + OutputStatements(indent + 1, blockStatement->statement); m_writer.WriteLine(indent, "}"); } else if (statement->nodeType == HLSLNodeType_Technique) @@ -3869,7 +3198,7 @@ void MSLGenerator::OutputAttributes(int indent, HLSLAttribute* attribute, bool b } } -void MSLGenerator::OutputDeclaration(HLSLDeclaration* declaration, const HLSLFunction* function) +void MSLGenerator::OutputDeclaration(HLSLDeclaration* declaration) { if (IsSamplerType(declaration->type)) { @@ -3893,12 +3222,12 @@ void MSLGenerator::OutputDeclaration(HLSLDeclaration* declaration, const HLSLFun } else { - OutputDeclaration(declaration->type, declaration->name, declaration->assignment, function); + OutputDeclaration(declaration->type, declaration->name, declaration->assignment); declaration = declaration->nextDeclaration; while (declaration != NULL) { m_writer.Write(","); - OutputDeclarationBody(declaration->type, declaration->name, declaration->assignment, function); + OutputDeclarationBody(declaration->type, declaration->name, declaration->assignment); declaration = declaration->nextDeclaration; }; } @@ -3981,14 +3310,14 @@ void MSLGenerator::OutputBuffer(int indent, HLSLBuffer* buffer) if (!field->hidden) { m_writer.BeginLine(indent + 1, RawStr(field->fileName), field->line); - OutputDeclaration(field->type, field->name, field->assignment, NULL, false, false, /*alignment=*/0); + OutputDeclaration(field->type, field->name, field->assignment, false, false, /*alignment=*/0); m_writer.EndLine(";"); } field = (HLSLDeclaration*)field->nextStatement; } m_writer.WriteLine(indent, "};"); - m_writer.WriteLine(indent, "constant Uniforms_%s & %s;", RawStr(buffer->name), RawStr(buffer->name)); + m_writer.WriteLine(indent, "constant Uniforms_%s& %s;", RawStr(buffer->name), RawStr(buffer->name)); } void MSLGenerator::OutputFunction(int indent, const HLSLFunction* function) @@ -4000,11 +3329,11 @@ void MSLGenerator::OutputFunction(int indent, const HLSLFunction* function) m_writer.Write("%s %s(", RawStr(returnTypeName), RawStr(functionName)); const eastl::vector& arguments = function->args; - OutputArguments(arguments, function); + OutputArguments(arguments); m_writer.EndLine(")"); m_writer.WriteLine(indent, "{"); - OutputStatements(indent + 1, function->statement, function); + OutputStatements(indent + 1, function->statement); m_writer.WriteLine(indent, "};"); } @@ -4057,7 +3386,7 @@ static const HLSLType* commonScalarType(const HLSLType& lhs, const HLSLType& rhs return NULL; } -void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* dstType, HLSLExpression* parentExpression, const HLSLFunction* function, bool needsEndParen) +void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* dstType, HLSLExpression* parentExpression, bool needsEndParen) { bool cast = dstType != NULL && !GetCanImplicitCast(expression->expressionType, *dstType); if (expression->nodeType == HLSLNodeType_CastingExpression) @@ -4077,7 +3406,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* { HLSLInitListExpression* initExpression = static_cast(expression); m_writer.Write("{"); - OutputExpressionList(initExpression->initExpressions, function); + OutputExpressionList(initExpression->initExpressions); m_writer.Write("}"); } else if (expression->nodeType == HLSLNodeType_IdentifierExpression) @@ -4105,7 +3434,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write(""); } //add buffer's name - else if (function != NULL && !matchFunctionArgumentsIdentifiersVec(function->args, name) && pDeclaration->buffer) + else if (pDeclaration->buffer) { m_writer.Write("%s.%s", RawStr(pDeclaration->buffer->name), RawStr(name)); } @@ -4119,9 +3448,8 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* if (funct != NULL && funct->functionExpression) { - OutputExpression(funct->functionExpression, dstType, parentExpression, function, needsEndParen); + OutputExpression(funct->functionExpression, dstType, parentExpression, needsEndParen); } - } else { @@ -4130,37 +3458,12 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write("%s.", RawStr(pDeclaration->buffer->name)); } - - // if it is one of PushConstantBuffer's data's Name - for (int index = 0; index < m_PushConstantBuffers.size(); index++) - { - HLSLBuffer* buffer = static_cast(m_PushConstantBuffers[index]); - HLSLDeclaration* field = buffer->field; - - while (field != NULL) - { - if (!field->hidden) - { - if (String_Equal(field->name, name)) - { - m_writer.Write("%s.%s", RawStr(buffer->name), RawStr(name)); - return; - } - } - field = (HLSLDeclaration*)field->nextStatement; - } - } - m_writer.Write("%s", RawStr(name)); } } else if (expression->nodeType == HLSLNodeType_CastingExpression) { - HLSLCastingExpression* castingExpression = static_cast(expression); - OutputCast(castingExpression->type); - m_writer.Write("("); - OutputExpression(castingExpression->expression, NULL, castingExpression, function, false); - m_writer.Write(")"); + OutputCastingExpression(static_cast(expression)); } else if (expression->nodeType == HLSLNodeType_ConstructorExpression) { @@ -4180,11 +3483,11 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* // uint3 contstructor. But in metal, that code causes an illegal cast. So to fix it, we will // get the base type of the constructor (uint in this case), and for each parameter, do // a cast if necessary. - OutputExpressionListConstructor(constructorExpression->params, function, expectedScalarType); + OutputExpressionListConstructor(constructorExpression->params, expectedScalarType); } else { - OutputExpressionList(constructorExpression->params, function); + OutputExpressionList(constructorExpression->params); } m_writer.Write(")"); @@ -4239,11 +3542,11 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* if (pre) { m_writer.Write("%s", CHECK_CSTR(op)); - OutputExpression(unaryExpression->expression, NULL, unaryExpression, function, needsEndParen); + OutputExpression(unaryExpression->expression, NULL, unaryExpression, needsEndParen); } else { - OutputExpression(unaryExpression->expression, NULL, unaryExpression, function, needsEndParen); + OutputExpression(unaryExpression->expression, NULL, unaryExpression, needsEndParen); m_writer.Write("%s", CHECK_CSTR(op)); } if (addParenthesis) m_writer.Write(")"); @@ -4264,11 +3567,11 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* rewrite_assign = true; m_writer.Write("set_column("); - OutputExpression(arrayAccess->array, NULL, NULL, function, needsEndParen); + OutputExpression(arrayAccess->array, NULL, NULL, needsEndParen); m_writer.Write(", "); - OutputExpression(arrayAccess->index, NULL, NULL, function, needsEndParen); + OutputExpression(arrayAccess->index, NULL, NULL, needsEndParen); m_writer.Write(", "); - OutputExpression(binaryExpression->expression2, NULL, NULL, function, needsEndParen); + OutputExpression(binaryExpression->expression2, NULL, NULL, needsEndParen); m_writer.Write(")"); } } @@ -4317,11 +3620,11 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* HLSLArrayAccess* arrayAccess = static_cast(binaryExpression->expression1); if ((binaryExpression->binaryOp == HLSLBinaryOp_Assign) && (binaryExpression->expression1->nodeType == HLSLArrayAccess::s_type) && IsRWTexture(arrayAccess->array->expressionType.baseType)) { - OutputExpression(arrayAccess->array, NULL, binaryExpression, function, true); + OutputExpression(arrayAccess->array, NULL, binaryExpression, true); m_writer.Write(".write("); - OutputExpression(binaryExpression->expression2, NULL, binaryExpression, function, true); + OutputExpression(binaryExpression->expression2, NULL, binaryExpression, true); switch (arrayAccess->array->expressionType.baseType) { @@ -4344,7 +3647,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* break; } - OutputExpression(arrayAccess->index, NULL, NULL, function, true); + OutputExpression(arrayAccess->index, NULL, NULL, true); switch (arrayAccess->array->expressionType.baseType) { @@ -4353,7 +3656,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* break; case HLSLBaseType_RWTexture1DArray: m_writer.Write(").x, uint2("); - OutputExpression(arrayAccess->index, NULL, NULL, function, true); + OutputExpression(arrayAccess->index, NULL, NULL, true); m_writer.Write(").y"); break; case HLSLBaseType_RWTexture2D: @@ -4361,7 +3664,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* break; case HLSLBaseType_RWTexture2DArray: m_writer.Write(").xy, uint3("); - OutputExpression(arrayAccess->index, NULL, NULL, function, true); + OutputExpression(arrayAccess->index, NULL, NULL, true); m_writer.Write(").z"); break; case HLSLBaseType_RWTexture3D: @@ -4375,10 +3678,10 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* } else { - OutputExpression(binaryExpression->expression1, dstType1, binaryExpression, function, needsEndParen); + OutputExpression(binaryExpression->expression1, dstType1, binaryExpression, needsEndParen); m_writer.Write("%s", CHECK_CSTR(op)); - OutputExpression(binaryExpression->expression2, dstType2, binaryExpression, function, true); + OutputExpression(binaryExpression->expression2, dstType2, binaryExpression, true); } } @@ -4392,21 +3695,19 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* HLSLConditionalExpression* conditionalExpression = static_cast(expression); // @@ Remove parenthesis. m_writer.Write("(("); - OutputExpression(conditionalExpression->condition, NULL, NULL, function, true); + OutputExpression(conditionalExpression->condition, NULL, NULL, true); m_writer.Write(")?("); - OutputExpression(conditionalExpression->trueExpression, NULL, NULL, function, true); + OutputExpression(conditionalExpression->trueExpression, NULL, NULL, true); m_writer.Write("):("); - OutputExpression(conditionalExpression->falseExpression, NULL, NULL, function, true); + OutputExpression(conditionalExpression->falseExpression, NULL, NULL, true); m_writer.Write("))"); } else if (expression->nodeType == HLSLNodeType_MemberAccess) { HLSLMemberAccess* memberAccess = static_cast(expression); - bool addParenthesis; - if (!needsEndParen) - addParenthesis = false; - else - addParenthesis = true; + bool addParenthesis = needsEndParen; + + bool scalarSwizzle = false; //compare the length of swizzling if (memberAccess->swizzle) @@ -4417,74 +3718,27 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* HLSLArrayAccess * arrayAccess = (HLSLArrayAccess*)memberAccess->object; baseType = arrayAccess->expressionType.elementType; } + scalarSwizzle = isScalarType(baseType); - int parentLength = 0; - switch (baseType) + if (scalarSwizzle) { - case HLSLBaseType_Float: - case HLSLBaseType_Half: - case HLSLBaseType_Min16Float: - case HLSLBaseType_Min10Float: - case HLSLBaseType_Bool: - case HLSLBaseType_Int: - case HLSLBaseType_Uint: - parentLength = 1; - break; - - case HLSLBaseType_Float2: - case HLSLBaseType_Half2: - case HLSLBaseType_Min16Float2: - case HLSLBaseType_Min10Float2: - case HLSLBaseType_Bool2: - case HLSLBaseType_Int2: - case HLSLBaseType_Uint2: - parentLength = 2; - break; - - case HLSLBaseType_Float3: - case HLSLBaseType_Half3: - case HLSLBaseType_Min16Float3: - case HLSLBaseType_Min10Float3: - case HLSLBaseType_Bool3: - case HLSLBaseType_Int3: - case HLSLBaseType_Uint3: - parentLength = 3; - break; - - case HLSLBaseType_Float4: - case HLSLBaseType_Half4: - case HLSLBaseType_Min16Float4: - case HLSLBaseType_Min10Float4: - case HLSLBaseType_Bool4: - case HLSLBaseType_Int4: - case HLSLBaseType_Uint4: - parentLength = 4; - break; - default: - break; + OutputDeclarationType(memberAccess->expressionType); + addParenthesis = true; } - - int swizzleLength = (int)strlen(RawStr(memberAccess->field)); - - // this cast seems incorrect. for example, if the swizzle is .w, you would still - // need a 4 channel vector even though strlen(w) = 1 - - //if (parentLength < swizzleLength) - // m_writer.Write("%s", RawStr(GetTypeName(expression->expressionType))); } if (addParenthesis) { m_writer.Write("("); } - OutputExpression(memberAccess->object, NULL, NULL, function, true); + OutputExpression(memberAccess->object, NULL, NULL, true); if (addParenthesis) { m_writer.Write(")"); } - - m_writer.Write(".%s", RawStr(memberAccess->field)); + if (!scalarSwizzle) + m_writer.Write(".%s", RawStr(memberAccess->field)); } else if (expression->nodeType == HLSLNodeType_ArrayAccess) { @@ -4497,19 +3751,19 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* int vecLen = (indexType - scalarType) + 1; - OutputExpression(arrayAccess->array, NULL, NULL, function, true); + OutputExpression(arrayAccess->array, NULL, NULL, true); m_writer.Write(".read("); m_writer.Write("("); - OutputExpression(arrayAccess->index, NULL, NULL, function, true); + OutputExpression(arrayAccess->index, NULL, NULL, true); m_writer.Write(").xy"); m_writer.Write(")"); } else { - OutputExpression(arrayAccess->array, NULL, expression, function, true); + OutputExpression(arrayAccess->array, NULL, expression, true); m_writer.Write("["); - OutputExpression(arrayAccess->index, NULL, NULL, function, true); + OutputExpression(arrayAccess->index, NULL, NULL, true); m_writer.Write("]"); } } @@ -4530,17 +3784,17 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* if (m_options.flags & Flag_PackMatrixRowMajor) { m_writer.Write("%s((", CHECK_CSTR(prefix)); - OutputExpression(params[1], NULL, NULL, function, true); + OutputExpression(params[1], NULL, NULL, true); m_writer.Write(")%s(", CHECK_CSTR(infix)); - OutputExpression(params[0], NULL, NULL, function, true); + OutputExpression(params[0], NULL, NULL, true); m_writer.Write("))"); } else { m_writer.Write("%s((", CHECK_CSTR(prefix)); - OutputExpression(params[0], NULL, NULL, function, true); + OutputExpression(params[0], NULL, NULL, true); m_writer.Write(")%s(", CHECK_CSTR(infix)); - OutputExpression(params[1], NULL, NULL, function, true); + OutputExpression(params[1], NULL, NULL, true); m_writer.Write("))"); } } @@ -4552,9 +3806,9 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* CachedString typeName = GetTypeName(retType); m_writer.Write("%s((%s)",RawStr(name),RawStr(typeName)); - OutputExpression(params[0],NULL,NULL,functionCall->function,false); + OutputExpression(params[0],NULL,NULL,false); m_writer.Write(",(%s)",RawStr(typeName)); - OutputExpression(params[1], NULL, NULL, functionCall->function, false); + OutputExpression(params[1], NULL, NULL, false); m_writer.Write(")"); } else if (String_Equal(name, "Sample") || String_Equal(name, "SampleLevel") || String_Equal(name, "SampleBias") || @@ -4562,7 +3816,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* { ASSERT_PARSER(params.size() >= 3); - OutputExpression(params[0], NULL, NULL, function, true); + OutputExpression(params[0], NULL, NULL, true); if (String_Equal(name, "Sample")) m_writer.Write(".%s(", CHECK_CSTR("sample")); @@ -4576,11 +3830,11 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write(".%s(", CHECK_CSTR("gather")); //should be sampler - OutputExpression(params[1], NULL, NULL, function, true); + OutputExpression(params[1], NULL, NULL, true); m_writer.Write(", "); - OutputExpression(params[2], NULL, NULL, function, true); + OutputExpression(params[2], NULL, NULL, true); //TODO: fix!! if (params[0]->expressionType.baseType == HLSLBaseType_Texture1DArray || @@ -4608,7 +3862,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* } ///Print again - OutputExpression(params[2], NULL, NULL, function, true); + OutputExpression(params[2], NULL, NULL, true); switch (params[0]->expressionType.baseType) { @@ -4633,7 +3887,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* if (params.size() > 3) { m_writer.Write(", level("); - OutputExpression(params[3], NULL, NULL, function, true); + OutputExpression(params[3], NULL, NULL, true); m_writer.Write(")"); } @@ -4656,11 +3910,11 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write(2, ""); } - OutputExpression(params[i], NULL, NULL, function, true); + OutputExpression(params[i], NULL, NULL, true); m_writer.Write(" = "); - OutputExpression(params[0], NULL, NULL, function, true); + OutputExpression(params[0], NULL, NULL, true); if (i == 1) m_writer.Write(".get_width("); @@ -4692,29 +3946,25 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* //for Texture if (IsTexture(params[0]->expressionType)) { - OutputExpression(params[0], NULL, NULL, function, false); - switch (params[0]->expressionType.baseType) + HLSLBaseType textureType = params[0]->expressionType.baseType; + + OutputExpression(params[0], NULL, NULL, false); + + m_writer.Write(".read("); + switch (textureType) { case HLSLBaseType_Texture1D: - m_writer.Write(".read("); - break; case HLSLBaseType_Texture1DArray: - m_writer.Write(".read(uint2("); + m_writer.Write("(uint)("); break; + case HLSLBaseType_Texture2DMS: + case HLSLBaseType_Texture2DMSArray: case HLSLBaseType_Texture2D: - m_writer.Write(".read("); - break; case HLSLBaseType_Texture2DArray: - m_writer.Write(".read(uint3("); + m_writer.Write("uint2("); break; case HLSLBaseType_Texture3D: - m_writer.Write(".read("); - break; - case HLSLBaseType_Texture2DMS: - m_writer.Write(".read("); - break; - case HLSLBaseType_Texture2DMSArray: - m_writer.Write(".read(uint3("); + m_writer.Write("uint3("); break; case HLSLBaseType_TextureCube: m_writer.Write(""); @@ -4726,39 +3976,90 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* break; } - OutputExpressionList(functionCall->params, function, 1); - - //HLSL -> MSL - switch (params[0]->expressionType.baseType) + //location + OutputExpression(functionCall->params[1], NULL, NULL, true); + switch (textureType) { case HLSLBaseType_Texture1D: - m_writer.Write(".x"); - break; case HLSLBaseType_Texture1DArray: - m_writer.Write(").x, uint2("); - OutputExpressionList(functionCall->params, function, 1); - m_writer.Write(").y"); + m_writer.Write(".x"); break; case HLSLBaseType_Texture2D: - m_writer.Write(".xy"); - break; case HLSLBaseType_Texture2DArray: - m_writer.Write(").xy, uint3("); - OutputExpressionList(functionCall->params, function, 1); - m_writer.Write(").z"); + case HLSLBaseType_Texture2DMS: + case HLSLBaseType_Texture2DMSArray: + m_writer.Write(".xy"); break; case HLSLBaseType_Texture3D: m_writer.Write(".xyz"); break; + default: + break; + } + + //offset + switch (textureType) + { + case HLSLBaseType_Texture1D: + case HLSLBaseType_Texture1DArray: + case HLSLBaseType_Texture2D: + case HLSLBaseType_Texture2DArray: + case HLSLBaseType_Texture3D: + if (functionCall->params.size() > 2) + { + m_writer.Write("+"); + OutputExpression(functionCall->params[2], NULL, NULL, true); + } + break; case HLSLBaseType_Texture2DMS: + case HLSLBaseType_Texture2DMSArray: + if (functionCall->params.size() > 3) + { + m_writer.Write("+"); + OutputExpression(functionCall->params[3], NULL, NULL, true); + } + break; + default: break; + } + m_writer.Write(")"); + + // sample index + switch (textureType) + { + case HLSLBaseType_Texture2DMS: case HLSLBaseType_Texture2DMSArray: + m_writer.Write(", "); + OutputExpression(functionCall->params[2], NULL, NULL, true); break; - case HLSLBaseType_TextureCube: - m_writer.Write(""); + default: break; - case HLSLBaseType_TextureCubeArray: - m_writer.Write(""); + } + + // array index + switch (textureType) + { + case HLSLBaseType_Texture1DArray: + case HLSLBaseType_Texture2DArray: + case HLSLBaseType_Texture2DMSArray: + case HLSLBaseType_Texture2DMS: + m_writer.Write(", "); + OutputExpression(functionCall->params[1], NULL, NULL, true); + m_writer.Write(textureType == HLSLBaseType_Texture1DArray ? ".y" : ".z"); + break; + default: + break; + } + + //lod + switch (textureType) + { + case HLSLBaseType_Texture2D: + case HLSLBaseType_Texture2DArray: + case HLSLBaseType_Texture3D: + m_writer.Write(", "); + OutputExpression(functionCall->params[1], NULL, NULL, true); + m_writer.Write(textureType == HLSLBaseType_Texture2D ? ".z" : ".w"); break; default: break; @@ -4769,8 +4070,9 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* else { //for buffers + OutputExpression(functionCall->params[0], NULL, NULL, true); m_writer.Write("["); - OutputExpressionList(functionCall->params, function); + OutputExpression(functionCall->params[1], NULL, NULL, false); m_writer.Write("]"); } } @@ -4778,15 +4080,15 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* { ASSERT_PARSER(params.size() == 3); - OutputExpression(params[0], NULL, NULL, function, false); + OutputExpression(params[0], NULL, NULL, false); m_writer.Write("["); - OutputExpression(params[1], NULL, NULL, function, false); + OutputExpression(params[1], NULL, NULL, false); m_writer.Write("]"); m_writer.Write(" = "); - OutputExpression(params[2], NULL, NULL, function, false); + OutputExpression(params[2], NULL, NULL, false); } else if (String_Equal(name, "InterlockedAdd") || String_Equal(name, "InterlockedAnd") || @@ -4800,8 +4102,8 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* //check the number of arguements if (params.size() == 3) { - //OutputExpression(expression->nextExpression->nextExpression, NULL, NULL, function, true); - OutputExpression(params[2], NULL, NULL, function, true); + //OutputExpression(expression->nextExpression->nextExpression, NULL, NULL, true); + OutputExpression(params[2], NULL, NULL, true); m_writer.Write(" = "); } @@ -4846,7 +4148,7 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* m_writer.Write(", "); } - OutputExpression(params[i], NULL, NULL, function, true); + OutputExpression(params[i], NULL, NULL, true); } m_writer.Write(", memory_order_relaxed)"); @@ -4859,16 +4161,16 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* HLSLExpression* sinArgument = params[1]; HLSLExpression* cosArgument = params[2]; - OutputExpression(sinArgument, NULL, NULL, functionCall->function, true); + OutputExpression(sinArgument, NULL, NULL, true); m_writer.Write(" = "); m_writer.Write("sincos("); - OutputExpression(angleArgument, NULL, NULL, functionCall->function, true); + OutputExpression(angleArgument, NULL, NULL, true); m_writer.Write(", "); - OutputExpression(cosArgument, NULL, NULL, functionCall->function, true); + OutputExpression(cosArgument, NULL, NULL, true); m_writer.Write(")"); } @@ -4911,34 +4213,60 @@ void MSLGenerator::OutputExpression(HLSLExpression* expression, const HLSLType* } } -bool MSLGenerator::matchFunctionArgumentsIdentifiersVec(const eastl::vector < HLSLArgument* > & arguments, const CachedString & name) +void MSLGenerator::OutputCast(const HLSLType& type) { - for (int i = 0; i < arguments.size(); i++) + if (type.baseType == HLSLBaseType_Float3x3) { - HLSLArgument * argument = arguments[i]; - if (String_Equal(argument->name, name)) - return true; + m_writer.Write("matrix_ctor"); + } + else + { + m_writer.Write("("); + OutputDeclarationType(type); + m_writer.Write(")"); } - - return false; } -void MSLGenerator::OutputCast(const HLSLType& type) +void MSLGenerator::OutputCastingExpression(HLSLCastingExpression* castExpr) { - if (type.baseType == HLSLBaseType_Float3x3) + HLSLType& srcType = castExpr->expression->expressionType; + HLSLType& dstType = castExpr->expressionType; + + const BaseTypeDescription& srcTypeDesc = BASE_TYPE_DESC[srcType.baseType]; + const BaseTypeDescription& dstTypeDesc = BASE_TYPE_DESC[dstType.baseType]; + + bool are1D = dstTypeDesc.numRows == 1 && srcTypeDesc.numRows == 1; + bool useConstructor = are1D && (dstTypeDesc.numComponents > 1 && srcTypeDesc.numComponents == 1 || srcTypeDesc.numericType != dstTypeDesc.numericType); + bool isSlicing = are1D && srcTypeDesc.numComponents > dstTypeDesc.numComponents; + ASSERT_PARSER(!isSlicing || isSlicing && dstTypeDesc.numComponents < 4) + + if (useConstructor) + { + // Output constructor + m_writer.Write("%s", GetTypeName(dstType)); + } + else if (dstType.baseType == HLSLBaseType_Float3x3) { m_writer.Write("matrix_ctor"); } - else + else if (!isSlicing) { m_writer.Write("("); - OutputDeclarationType(type); + OutputDeclarationType(dstType); m_writer.Write(")"); } + + const char* slicingSwizzle[3] = {").x", ").xy", ").xyz"}; + m_writer.Write(useConstructor ? "(" : ""); + m_writer.Write(isSlicing ? "(" : ""); + OutputExpression(castExpr->expression, NULL, castExpr, false); + m_writer.Write(isSlicing ? slicingSwizzle[dstTypeDesc.numComponents - 1] : ""); + m_writer.Write(useConstructor ? ")" : ""); + } // Called by the various Output functions -void MSLGenerator::OutputArguments(const eastl::vector & arguments, const HLSLFunction* function) +void MSLGenerator::OutputArguments(const eastl::vector & arguments) { size_t numWritten = 0; @@ -4969,16 +4297,16 @@ void MSLGenerator::OutputArguments(const eastl::vector & argument } m_writer.Write(0, ""); - OutputDeclaration(argument->type, argument->name, argument->defaultValue, function, isRef, isConst); + OutputDeclaration(argument->type, argument->name, argument->defaultValue, isRef, isConst); numWritten++; } } -void MSLGenerator::OutputDeclaration(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, const HLSLFunction* function, bool isRef, bool isConst, int alignment) +void MSLGenerator::OutputDeclaration(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, bool isRef, bool isConst, int alignment) { OutputDeclarationType(type, isRef, isConst, alignment); - OutputDeclarationBody(type, name, assignment, function, isRef); + OutputDeclarationBody(type, name, assignment, isRef); } void MSLGenerator::OutputDeclarationType(const HLSLType& type, bool isRef, bool isConst, int alignment) @@ -5066,7 +4394,7 @@ void MSLGenerator::OutputDeclarationType(const HLSLType& type, bool isRef, bool } } -void MSLGenerator::OutputDeclarationBody(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, const HLSLFunction* function, bool isRef) +void MSLGenerator::OutputDeclarationBody(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, bool isRef) { if (isRef) { @@ -5091,30 +4419,30 @@ void MSLGenerator::OutputDeclarationBody(const HLSLType& type, const CachedStrin if (type.array) { m_writer.Write("{ "); - OutputExpression(assignment, &type, NULL, function, true); + OutputExpression(assignment, &type, NULL, true); m_writer.Write(" }"); } else { - OutputExpression(assignment, &type, NULL, function, true); + OutputExpression(assignment, &type, NULL, true); } } } -void MSLGenerator::OutputExpressionList(const eastl::vector& expressions, const HLSLFunction* function, size_t start) +void MSLGenerator::OutputExpressionList(const eastl::vector& expressions, size_t start) { for (size_t i = start; i < expressions.size(); i++) { ASSERT_PARSER(expressions[i] != NULL); - if (i > 0) + if (i > start) { m_writer.Write(", "); } - OutputExpression(expressions[i], NULL, NULL, function, true); + OutputExpression(expressions[i], NULL, NULL, true); } } -void MSLGenerator::OutputExpressionListConstructor(const eastl::vector& expressions, const HLSLFunction* function, HLSLBaseType expectedScalarType) +void MSLGenerator::OutputExpressionListConstructor(const eastl::vector& expressions, HLSLBaseType expectedScalarType) { for (size_t i = 0; i < expressions.size(); ++i) { @@ -5135,7 +4463,7 @@ void MSLGenerator::OutputExpressionListConstructor(const eastl::vectorparams, functionCall->function); + OutputExpressionList(functionCall->params); m_writer.Write(", 3"); m_writer.Write(")"); @@ -5196,7 +4524,7 @@ void MSLGenerator::OutputFunctionCall(HLSLFunctionCall* functionCall) m_writer.Write("%s(", RawStr(name)); - OutputExpressionList(functionCall->params, functionCall->function); + OutputExpressionList(functionCall->params); m_writer.Write(", 1"); m_writer.Write(")"); @@ -5208,7 +4536,7 @@ void MSLGenerator::OutputFunctionCall(HLSLFunctionCall* functionCall) m_writer.Write("%s(", RawStr(name)); - OutputExpressionList(functionCall->params, functionCall->function); + OutputExpressionList(functionCall->params); m_writer.Write(", 2"); m_writer.Write(")"); @@ -5305,7 +4633,7 @@ void MSLGenerator::OutputFunctionCall(HLSLFunctionCall* functionCall) m_writer.Write("%s(", RawStr(name)); - OutputExpressionList(functionCall->params, functionCall->function); + OutputExpressionList(functionCall->params); m_writer.Write(")"); } diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.h b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.h index 2386cd422e..a3a6ea756a 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.h +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/MSLGenerator.h @@ -21,17 +21,17 @@ class StringLibrary; class MSLGenerator { public: - enum Target - { - Target_VertexShader, - Target_FragmentShader, + enum Target + { + Target_VertexShader, + Target_FragmentShader, Target_HullShader, Target_DomainShader, Target_GeometryShader, Target_ComputeShader, - }; - - enum Flags + }; + + enum Flags { Flag_ConstShadowSampler = 1 << 0, Flag_PackMatrixRowMajor = 1 << 1, @@ -45,9 +45,11 @@ class MSLGenerator unsigned int textureRegisterOffset; unsigned int bufferRegisterOffset; + bool useArgBufs; + bool bindingRequired; eastl::vector < BindingOverride > bindingOverrides; - + eastl::vector < BindingShift >shiftVec; int (*attributeCallback)(const char* name, unsigned int index); @@ -58,6 +60,8 @@ class MSLGenerator textureRegisterOffset = 0; attributeCallback = NULL; + useArgBufs = true; + bindingRequired = false; bindingOverrides.clear(); } @@ -81,33 +85,17 @@ class MSLGenerator CachedString registerName; bool bStructuredBuffer; - ClassArgument * nextArg; - ClassArgument(CachedString nameParam, HLSLType typeParam, CachedString registerNameParam, bool bStructuredBufferParam = false) : name(nameParam), type(typeParam), registerName(registerNameParam), bStructuredBuffer(bStructuredBufferParam) - { - nextArg = NULL; - } - - ClassArgument(CachedString nameParam, const char* preprocessorContents, HLSLType typeParam, CachedString registerNameParam = CachedString(), bool bStructuredBufferParam = false) : - name(nameParam), type(typeParam), registerName(registerNameParam), bStructuredBuffer(bStructuredBufferParam) - { - nextArg = NULL; - } - + {} }; - void AddClassArgument(ClassArgument * arg); - void Prepass(HLSLTree* tree, Target target, HLSLFunction* entryFunction, HLSLFunction* secondaryEntryFunction); - void CleanPrepass(); - + int GetBufferRegister(const CachedString & cachedName); int GetTextureRegister(const CachedString & cachedName); int GetSamplerRegister(const CachedString & cachedName); - - //bool DoesEntryUseName(HLSLFunction* entryFunction, const CachedString & name); void GetAllEntryUsedNames(StringLibrary & foundNames, eastl::hash_set < const HLSLFunction * > & foundFuncs, @@ -117,22 +105,23 @@ class MSLGenerator void PrependDeclarations(); - void OutputStatements(int indent, HLSLStatement* statement, const HLSLFunction* function); + void OutputStatements(int indent, HLSLStatement* statement); void OutputAttributes(int indent, HLSLAttribute* attribute, bool bMain); - void OutputDeclaration(HLSLDeclaration* declaration, const HLSLFunction* function); + void OutputDeclaration(HLSLDeclaration* declaration); void OutputStruct(int indent, HLSLStruct* structure); void OutputBuffer(int indent, HLSLBuffer* buffer); void OutputFunction(int indent, const HLSLFunction* function); - void OutputExpression(HLSLExpression* expression, const HLSLType* dstType, HLSLExpression* parentExpression, const HLSLFunction* function, bool needsEndParen); + void OutputExpression(HLSLExpression* expression, const HLSLType* dstType, HLSLExpression* parentExpression, bool needsEndParen); void OutputCast(const HLSLType& type); - - //void OutputArguments(HLSLArgument* argument, const HLSLFunction* function); - void OutputArguments(const eastl::vector& arguments, const HLSLFunction* function); - void OutputDeclaration(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, const HLSLFunction* function, bool isRef = false, bool isConst = false, int alignment = 0); + + void OutputArguments(const eastl::vector& arguments); + void OutputDeclaration(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, bool isRef = false, bool isConst = false, int alignment = 0); + void OutputDeclaration(const char* prefix, HLSLDeclaration* decl, bool use_ref, bool outputId); + void OutputCastingExpression(HLSLCastingExpression* castExpr); void OutputDeclarationType(const HLSLType& type, bool isConst = false, bool isRef = false, int alignment = 0); - void OutputDeclarationBody(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, const HLSLFunction* function, bool isRef = false); - void OutputExpressionListConstructor(const eastl::vector& expressions, const HLSLFunction* function, HLSLBaseType expectedScalarType); - void OutputExpressionList(const eastl::vector& expressionVec, const HLSLFunction* function, size_t start = 0); + void OutputDeclarationBody(const HLSLType& type, const CachedString & name, HLSLExpression* assignment, bool isRef = false); + void OutputExpressionListConstructor(const eastl::vector& expressions, HLSLBaseType expectedScalarType); + void OutputExpressionList(const eastl::vector& expressionVec, size_t start = 0); void OutputFunctionCall(HLSLFunctionCall* functionCall); CachedString GetTypeName(const HLSLType& type); @@ -140,17 +129,15 @@ class MSLGenerator CachedString TranslateInputSemantic(const CachedString & semantic, int incr); CachedString TranslateOutputSemantic(const CachedString & semantic); - void Error(const char* format, ...); - bool matchFunctionArgumentsIdentifiersVec(const eastl::vector < HLSLArgument* > & arguments, const CachedString & name); - - CachedString GetBuiltInSemantic(const CachedString & semantic, HLSLArgumentModifier modifier, const CachedString & argument = CachedString(), const CachedString & field = CachedString()); - CachedString MakeCached(const char * str); + void OutputShaderClass(const char* shaderClassName); + void OutputMain(HLSLTree* tree, HLSLFunction* entryFunction, HLSLFunction* secondaryEntryFunction, const char* shaderClassName); + private: CodeWriter m_writer; @@ -161,26 +148,19 @@ class MSLGenerator Target m_target; Options m_options; - bool m_error; + bool m_error; - ClassArgument * m_firstClassArgument; - ClassArgument * m_lastClassArgument; + eastl::vector m_Args; CachedString m_texIndexFuncName; - int attributeCounter; - - eastl::vector < HLSLBuffer* > m_RWBuffers; - eastl::vector < HLSLBuffer* > m_RWStructuredBuffers; - eastl::vector < HLSLBuffer* > m_PushConstantBuffers; - eastl::vector < HLSLStruct* > m_StructBuffers; + int attributeCounter; - StringLibrary * m_stringLibrary; + StringLibrary* m_stringLibrary; int m_nextTextureRegister; int m_nextSamplerRegister; int m_nextBufferRegister; // options start at 1 - }; diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/Parser.cpp b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/Parser.cpp index 8cd3e22bcc..1623f31ed2 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/Parser.cpp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Parser/Parser/Parser.cpp @@ -164,6 +164,7 @@ bool Parser::ProcessFile( MSLGenerator::Options mslOptions; mslOptions.bindingRequired = options.mOverrideRequired; mslOptions.bindingOverrides = options.mOverrideVec; + mslOptions.shiftVec = options.mShiftVec; parsedData.mIsGenerateOk = generator.Generate(&stringLibrary, &tree, (MSLGenerator::Target)options.mTarget, entryName.c_str(), mslOptions); parsedData.mGeneratedData = generator.GetResult(); diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Release/Parser.exe b/Common_3/ThirdParty/OpenSource/hlslparser/Release/Parser.exe index 0dd8ecb76a..6834514b5d 100644 Binary files a/Common_3/ThirdParty/OpenSource/hlslparser/Release/Parser.exe and b/Common_3/ThirdParty/OpenSource/hlslparser/Release/Parser.exe differ diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile.bat b/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile.bat index 91a323f4c5..39ab9ca8ac 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile.bat +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile.bat @@ -3,24 +3,24 @@ FOR %%A IN (*.geom) DO ..\Release\Parser.exe -gs -hlsl %%A -E main -Fo HLSL\%%A FOR %%A IN (*.frag) DO ..\Release\Parser.exe -fs -hlsl %%A -E main -Fo HLSL\%%A FOR %%A IN (*.comp) DO ..\Release\Parser.exe -cs -hlsl %%A -E main -Fo HLSL\%%A -FOR %%A IN (*.vert) DO ..\Release\Parser.exe -vs -glsl %%A -E main -Fo GLSL\%%A -FOR %%A IN (*.geom) DO ..\Release\Parser.exe -gs -glsl %%A -E main -Fo GLSL\%%A -FOR %%A IN (*.frag) DO ..\Release\Parser.exe -fs -glsl %%A -E main -Fo GLSL\%%A -FOR %%A IN (*.comp) DO ..\Release\Parser.exe -cs -glsl %%A -E main -Fo GLSL\%%A +FOR %%A IN (*.vert) DO ..\Release\Parser.exe -vs -glsl %%A -E main -Fo GLSL\%%A -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 +FOR %%A IN (*.geom) DO ..\Release\Parser.exe -gs -glsl %%A -E main -Fo GLSL\%%A -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 +FOR %%A IN (*.frag) DO ..\Release\Parser.exe -fs -glsl %%A -E main -Fo GLSL\%%A -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 +FOR %%A IN (*.comp) DO ..\Release\Parser.exe -cs -glsl %%A -E main -Fo GLSL\%%A -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 -FOR %%A IN (*.vert) DO ..\Release\Parser.exe -vs -msl %%A -E main -Fo Metal\%%A.metal -FOR %%A IN (*.geom) DO ..\Release\Parser.exe -gs -msl %%A -E main -Fo Metal\%%A.metal -FOR %%A IN (*.frag) DO ..\Release\Parser.exe -fs -msl %%A -E main -Fo Metal\%%A.metal -FOR %%A IN (*.comp) DO ..\Release\Parser.exe -cs -msl %%A -E main -Fo Metal\%%A.metal +FOR %%A IN (*.vert) DO ..\Release\Parser.exe -vs -msl %%A -E main -Fo Metal\%%A.metal -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 +FOR %%A IN (*.geom) DO ..\Release\Parser.exe -gs -msl %%A -E main -Fo Metal\%%A.metal -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 +FOR %%A IN (*.frag) DO ..\Release\Parser.exe -fs -msl %%A -E main -Fo Metal\%%A.metal -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 +FOR %%A IN (*.comp) DO ..\Release\Parser.exe -cs -msl %%A -E main -Fo Metal\%%A.metal -fvk-s-shift 8 0 -fvk-t-shift 16 0 -fvk-u-shift 24 0 mkdir SPV FOR %%A IN (GLSL\*) DO glslangValidator -V %%A -o SPV\%%~nxA mkdir DXIL -REM FOR %%A IN (HLSL\*.vert) DO dxc /T vs_6_0 %%A /Fo DXIL\%%~nxA -REM FOR %%A IN (HLSL\*.geom) DO dxc /T gs_6_0 %%A /Fo DXIL\%%~nxA -REM FOR %%A IN (HLSL\*.frag) DO dxc /T ps_6_0 %%A /Fo DXIL\%%~nxA -REM FOR %%A IN (HLSL\*.comp) DO dxc /T cs_6_0 %%A /Fo DXIL\%%~nxA +FOR %%A IN (HLSL\*.vert) DO dxc /T vs_6_0 %%A /Fo DXIL\%%~nxA +FOR %%A IN (HLSL\*.geom) DO dxc /T gs_6_0 %%A /Fo DXIL\%%~nxA +FOR %%A IN (HLSL\*.frag) DO dxc /T ps_6_0 %%A /Fo DXIL\%%~nxA +FOR %%A IN (HLSL\*.comp) DO dxc /T cs_6_0 %%A /Fo DXIL\%%~nxA REM FOR %%A IN (*.vert) DO ..\Release\Parser.exe -vs -orbis %%A -E main -Fo Orbis\%%A REM FOR %%A IN (*.frag) DO ..\Release\Parser.exe -fs -orbis %%A -E main -Fo Orbis\%%A \ No newline at end of file diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile_mac.bat b/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile_mac.bat new file mode 100644 index 0000000000..e5b7eb213b --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Test/compile_mac.bat @@ -0,0 +1,7 @@ +ssh %HLSPARSER_TEST_SSH% "mkdir HLSLParserTest" +sleep 1 +ssh %HLSPARSER_TEST_SSH% "rm HLSLParserTest/*" +sleep 1 +scp Metal/* %HLSPARSER_TEST_SSH%:HLSLParserTest +sleep 1 +ssh %HLSPARSER_TEST_SSH% 'for f in `ls HLSLParserTest/*.metal`; do xcrun -sdk macosx metal -c $f -o "${f}.air"; done' 2>compile_mac.log diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_arg_buffer.frag b/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_arg_buffer.frag new file mode 100644 index 0000000000..dfe3ba9e62 --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_arg_buffer.frag @@ -0,0 +1,35 @@ +struct Vertex_Output +{ + float4 Position : SV_POSITION; + float2 UV : TEXCOORD0; +}; + +Texture2D Texture00 : register(t0); +Texture2D Texture01; +Texture2D Texture10 : register(t1, space1); +Texture2D Texture11 : register(space1); +SamplerState Sampler00 : register(space2); +SamplerState Sampler01 : register(s3, space2); +SamplerState Sampler10 : register(s5); +SamplerState Sampler11 : register(space1); + +struct RCB +{ + float4 uMult; +}; + +ConstantBuffer RootConstant; + +cbuffer ContantBuffer1 : register(b1, space2) +{ + float4 uMult1; +} + +float4 main( Vertex_Output In ) : SV_TARGET +{ + return RootConstant.uMult * uMult1 * + (Texture00.Sample(Sampler00, In.UV) + + Texture01.Sample(Sampler01, In.UV) + + Texture10.Sample(Sampler10, In.UV) + + Texture11.Sample(Sampler11, In.UV)); +} \ No newline at end of file diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_cb_shadowing.frag b/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_cb_shadowing.frag new file mode 100644 index 0000000000..99ce106b41 --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_cb_shadowing.frag @@ -0,0 +1,30 @@ +struct Vertex_Output +{ + float4 Position : SV_POSITION; + float4 UV[5] : TEXCOORD0; + float4 Color : COLOR; +}; + +Texture2D Texture; +SamplerState Sampler; + +cbuffer CB_RootConstant +{ + float4 color; + float weights[5]; +}; + +float apply_filter(Texture2D tex, SamplerState smp, float4 uv[5], float color) +{ + float result = 0.0; + for(uint i = 0; i < 5; ++i) + { + result += Texture.Sample(Sampler, uv[i]) * weights[i]; + } + return color * result; +} + +float4 main( Vertex_Output In ) : SV_TARGET +{ + return In.Color * apply_filter(Texture, Sampler, In.UV, color.r); +} diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_texture2d_indexing.comp b/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_texture2d_indexing.comp index de6fd9c5fa..b2500653d5 100644 --- a/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_texture2d_indexing.comp +++ b/Common_3/ThirdParty/OpenSource/hlslparser/Test/r_texture2d_indexing.comp @@ -3,10 +3,21 @@ Texture2D lightbuffer : register(t1); RWTexture2D outputRT : register(u2); +Texture2D in0 : register(t2); +RWTexture2D out0 : register(u0); + +Texture2D in1 : register(t3); +RWTexture2D out1 : register(u1); + [numthreads(16, 16, 1)] void main(uint3 Gid : SV_GroupID, uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID, uint GI : SV_GroupIndex) { float3 albedo = albedobuffer[DTid.xy].xyz; float3 diffuse = lightbuffer[DTid.xy].xyz; outputRT[DTid.xy] = float4(diffuse*albedo, 0); -} \ No newline at end of file + + int3 v0 = in0[DTid.xy].xyz; + out0[DTid.xy] =int4(v0, 0); + uint3 v1 = in1[DTid.xy].xyz; + out1[DTid.xy] =uint4(v1, 0); + } \ No newline at end of file diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Debug/Parser.exe b/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Debug/Parser.exe index 028160412f..9a8410b798 100644 Binary files a/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Debug/Parser.exe and b/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Debug/Parser.exe differ diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Release/Parser.exe b/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Release/Parser.exe index 0dd8ecb76a..6834514b5d 100644 Binary files a/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Release/Parser.exe and b/Common_3/ThirdParty/OpenSource/hlslparser/UI/HLSLParser/HLSLParser/bin/x64/Release/Parser.exe differ diff --git a/Common_3/ThirdParty/OpenSource/hlslparser/Web/WebTranslator/WebTranslator/wwwroot/app/Parser.exe b/Common_3/ThirdParty/OpenSource/hlslparser/Web/WebTranslator/WebTranslator/wwwroot/app/Parser.exe index 0dd8ecb76a..6834514b5d 100644 Binary files a/Common_3/ThirdParty/OpenSource/hlslparser/Web/WebTranslator/WebTranslator/wwwroot/app/Parser.exe and b/Common_3/ThirdParty/OpenSource/hlslparser/Web/WebTranslator/WebTranslator/wwwroot/app/Parser.exe differ diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj b/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj index 4a78ecb3c9..8b822ee6eb 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj @@ -37,6 +37,8 @@ + + @@ -48,6 +50,8 @@ + + diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj.filters b/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj.filters index dd0351762b..410265ea32 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj.filters +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/AndroidVisualStudio2017/src/animation/runtime/ozz_animation/ozz_animation.vcxproj.filters @@ -36,6 +36,12 @@ Source Files + + Source Files + + + Source Files + @@ -71,5 +77,11 @@ Header Files + + Header Files + + + Header Files + \ No newline at end of file diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/MacOS/ozz.xcodeproj/project.pbxproj b/Common_3/ThirdParty/OpenSource/ozz-animation/MacOS/ozz.xcodeproj/project.pbxproj index ced8a73a0d..96b77a91d0 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/MacOS/ozz.xcodeproj/project.pbxproj +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/MacOS/ozz.xcodeproj/project.pbxproj @@ -10,6 +10,10 @@ 0BB7DF96B6F04DB8B519DB24 /* blending_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5B38A8427D024BAAAD5D5BAE /* blending_job.cc */; }; 11E0A627A9074C7592DC9D2C /* skeleton_utils.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8CD3CA6CE9CB41BE81431880 /* skeleton_utils.cc */; }; 27B2FBEDDD824C47AB37E3A6 /* track_triggering_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = D972F37C2FA644DBA3708689 /* track_triggering_job.cc */; }; + 32839C2E2332DC9C0076D7D2 /* ik_two_bone_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 32B12D082332C5080087C13F /* ik_two_bone_job.cc */; }; + 32839C2F2332DD600076D7D2 /* ik_aim_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 32B12D0B2332C7D50087C13F /* ik_aim_job.cc */; }; + 32B12D092332C5090087C13F /* ik_two_bone_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 32B12D082332C5080087C13F /* ik_two_bone_job.cc */; }; + 32B12D0C2332C7D50087C13F /* ik_aim_job.cc in Sources */ = {isa = PBXBuildFile; fileRef = 32B12D0B2332C7D50087C13F /* ik_aim_job.cc */; }; 423BC752D25E4DCBA154DCC6 /* soa_math_archive.cc in Sources */ = {isa = PBXBuildFile; fileRef = 76E86DCA018846688B72C202 /* soa_math_archive.cc */; }; 49C0D02BEB1A47FFBB35B2A2 /* skeleton.cc in Sources */ = {isa = PBXBuildFile; fileRef = D7BD5A5DCF3C49D19939AC50 /* skeleton.cc */; }; 563C44DBF8704CFF9811865B /* string_archive.cc in Sources */ = {isa = PBXBuildFile; fileRef = C18117F6C1244768A3B5599C /* string_archive.cc */; }; @@ -101,6 +105,10 @@ 166F7EDB2B8A49D0BC3C05B3 /* animation_keyframe.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = animation_keyframe.h; path = src/animation/runtime/animation_keyframe.h; sourceTree = SOURCE_ROOT; }; 1E022C10C1F5468C8EB6633C /* soa_math_archive.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = soa_math_archive.h; path = include/ozz/base/maths/soa_math_archive.h; sourceTree = SOURCE_ROOT; }; 3159790D7843448187DB23A0 /* math_ex.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = math_ex.h; path = include/ozz/base/maths/math_ex.h; sourceTree = SOURCE_ROOT; }; + 32B12D082332C5080087C13F /* ik_two_bone_job.cc */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = ik_two_bone_job.cc; path = src/animation/runtime/ik_two_bone_job.cc; sourceTree = ""; }; + 32B12D0A2332C52D0087C13F /* ik_two_bone_job.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = ik_two_bone_job.h; path = include/ozz/animation/runtime/ik_two_bone_job.h; sourceTree = ""; }; + 32B12D0B2332C7D50087C13F /* ik_aim_job.cc */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = ik_aim_job.cc; path = src/animation/runtime/ik_aim_job.cc; sourceTree = ""; }; + 32B12D0E2332C8070087C13F /* ik_aim_job.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = ik_aim_job.h; path = include/ozz/animation/runtime/ik_aim_job.h; sourceTree = ""; }; 34100AA7E46F4BDA9FB99008 /* math_archive.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = math_archive.h; path = include/ozz/base/maths/math_archive.h; sourceTree = SOURCE_ROOT; }; 375D86465F184D0E8FCAFB18 /* math_archive.cc */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = math_archive.cc; path = src/base/maths/math_archive.cc; sourceTree = SOURCE_ROOT; }; 3CB2E8B31E9840C6B93C8023 /* platform.cc */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = platform.cc; path = src/base/platform.cc; sourceTree = SOURCE_ROOT; }; @@ -192,6 +200,8 @@ 18E55D5E3984440B87110F38 /* Source Files */ = { isa = PBXGroup; children = ( + 32B12D0B2332C7D50087C13F /* ik_aim_job.cc */, + 32B12D082332C5080087C13F /* ik_two_bone_job.cc */, 0F0A5A4A9672470898FE1AA8 /* animation.cc */, 5B38A8427D024BAAAD5D5BAE /* blending_job.cc */, 6598CCF06AB74D6996FB0582 /* local_to_model_job.cc */, @@ -306,6 +316,8 @@ C2507C84B8E849A0B273D75C /* Header Files */ = { isa = PBXGroup; children = ( + 32B12D0E2332C8070087C13F /* ik_aim_job.h */, + 32B12D0A2332C52D0087C13F /* ik_two_bone_job.h */, 0CDA539DA89D46C6859BA90A /* animation.h */, 75782F5DE21D4E79B5D65C1C /* blending_job.h */, A4AA01DEFA984C0AB14AE956 /* local_to_model_job.h */, @@ -498,10 +510,12 @@ 0BB7DF96B6F04DB8B519DB24 /* blending_job.cc in Sources */, 78AA3DC32EE246628240AA19 /* local_to_model_job.cc in Sources */, 716F07A9A82343F59E54092A /* sampling_job.cc in Sources */, + 32B12D0C2332C7D50087C13F /* ik_aim_job.cc in Sources */, 49C0D02BEB1A47FFBB35B2A2 /* skeleton.cc in Sources */, 11E0A627A9074C7592DC9D2C /* skeleton_utils.cc in Sources */, 6193CFCC2B89453ABFEBFC6F /* track.cc in Sources */, B6381419971842EBB8EAABC9 /* track_sampling_job.cc in Sources */, + 32B12D092332C5090087C13F /* ik_two_bone_job.cc in Sources */, 27B2FBEDDD824C47AB37E3A6 /* track_triggering_job.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -552,10 +566,12 @@ D0796AC2211ED7370028AFFD /* blending_job.cc in Sources */, D0796AC3211ED7370028AFFD /* local_to_model_job.cc in Sources */, D0796AC4211ED7370028AFFD /* sampling_job.cc in Sources */, + 32839C2F2332DD600076D7D2 /* ik_aim_job.cc in Sources */, D0796AC5211ED7370028AFFD /* skeleton.cc in Sources */, D0796AC6211ED7370028AFFD /* skeleton_utils.cc in Sources */, D0796AC7211ED7370028AFFD /* track.cc in Sources */, D0796AC8211ED7370028AFFD /* track_sampling_job.cc in Sources */, + 32839C2E2332DC9C0076D7D2 /* ik_two_bone_job.cc in Sources */, D0796AC9211ED7370028AFFD /* track_triggering_job.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/Ubuntu/ozz_animation.project b/Common_3/ThirdParty/OpenSource/ozz-animation/Ubuntu/ozz_animation.project index 74c3d35fa3..21eddceece 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/Ubuntu/ozz_animation.project +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/Ubuntu/ozz_animation.project @@ -6,6 +6,8 @@ + + @@ -17,6 +19,8 @@ + + diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/offline/ozz_animation_offline.vcxproj b/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/offline/ozz_animation_offline.vcxproj index 853b756e3a..5cb07dab23 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/offline/ozz_animation_offline.vcxproj +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/offline/ozz_animation_offline.vcxproj @@ -1,6 +1,10 @@  + + DebugDx11 + x64 + DebugDx x64 @@ -9,6 +13,10 @@ DebugVk x64 + + ReleaseDx11 + x64 + ReleaseDx x64 @@ -32,6 +40,11 @@ StaticLibrary MultiByte + + v141 + StaticLibrary + MultiByte + v141 StaticLibrary @@ -42,6 +55,11 @@ StaticLibrary MultiByte + + v141 + StaticLibrary + MultiByte + v141 StaticLibrary @@ -61,6 +79,10 @@ $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(ProjectDir)..\..\..\..\include;$(IncludePath) + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)..\..\..\..\include;$(IncludePath) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(ProjectDir)..\..\..\..\include;$(IncludePath) @@ -69,6 +91,10 @@ $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(ProjectDir)..\..\..\..\include;$(IncludePath) + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(ProjectDir)..\..\..\..\include;$(IncludePath) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(ProjectDir)..\..\..\..\include;$(IncludePath) @@ -78,6 +104,11 @@ $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + + + $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + + Level3 @@ -88,6 +119,16 @@ _CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) + + + Level3 + MultiThreadedDebugDLL + EnableFastChecks + Disabled + Disabled + _CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) + + Level3 @@ -108,6 +149,15 @@ _CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) + + + Level3 + None + $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + AnySuitable + _CRT_SECURE_NO_WARNINGS;_MBCS;%(PreprocessorDefinitions) + + Level3 diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj b/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj index a4b84c8f41..649f879946 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj @@ -125,7 +125,8 @@ true - ozz_base.lib + + @@ -138,7 +139,8 @@ true - ozz_base.lib + + @@ -152,7 +154,8 @@ true - ozz_base.lib + + @@ -164,7 +167,8 @@ true - ozz_base.lib + + @@ -176,7 +180,8 @@ true - ozz_base.lib + + @@ -188,16 +193,21 @@ true - ozz_base.lib + + + + + + diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj.filters b/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj.filters index 6982e1e864..73b992c520 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj.filters +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/Win64/src/animation/runtime/ozz_animation.vcxproj.filters @@ -28,6 +28,12 @@ Source Files + + Source Files + + + Source Files + @@ -63,6 +69,12 @@ Header Files + + Header Files + + + Header Files + diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj b/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj index 9366720672..d7af500945 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj @@ -134,10 +134,14 @@ + + + + diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj.filters b/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj.filters index 50322a8289..c4089f4f85 100644 --- a/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj.filters +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/Xbox/src/animation/runtime/ozz_animation.vcxproj.filters @@ -28,6 +28,12 @@ Source Files + + Source Files + + + Source Files + @@ -63,6 +69,12 @@ Header Files + + Header Files + + + Header Files + diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_aim_job.h b/Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_aim_job.h new file mode 100644 index 0000000000..ee00bcabac --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_aim_job.h @@ -0,0 +1,114 @@ +//----------------------------------------------------------------------------// +// // +// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation // +// and distributed under the MIT License (MIT). // +// // +// Copyright (c) 2019 Guillaume Blanc // +// // +// Permission is hereby granted, free of charge, to any person obtaining a // +// copy of this software and associated documentation files (the "Software"), // +// to deal in the Software without restriction, including without limitation // +// the rights to use, copy, modify, merge, publish, distribute, sublicense, // +// and/or sell copies of the Software, and to permit persons to whom the // +// Software is furnished to do so, subject to the following conditions: // +// // +// The above copyright notice and this permission notice shall be included in // +// all copies or substantial portions of the Software. // +// // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // +// DEALINGS IN THE SOFTWARE. // +// // +//----------------------------------------------------------------------------// + +#ifndef OZZ_OZZ_ANIMATION_RUNTIME_IK_AIM_JOB_H_ +#define OZZ_OZZ_ANIMATION_RUNTIME_IK_AIM_JOB_H_ + +#include "../../base/platform.h" + +#include "../../../../../../../../Common_3/OS/Math/MathTypes.h" + +namespace ozz { +// Forward declaration of math structures. +namespace math { +struct SimdQuaternion; +} + +namespace animation { + +// ozz::animation::IKAimJob rotates a joint so it aims at a target. Joint aim +// direction and up vectors can be different from joint axis. The job computes +// the transformation (rotation) that needs to be applied to the joints such +// that a provided forward vector (in joint local-space) aims at the target +// position (in skeleton model-space). Up vector (in joint local-space) is also +// used to keep the joint oriented in the same direction as the pole vector. +// The job also exposes an offset (in joint local-space) from where the forward +// vector should aim the target. +// Result is unstable if joint-to-target direction is parallel to pole vector, +// or if target is too close to joint position. +struct IKAimJob { + // Default constructor, initializes default values. + IKAimJob(); + + // Validates job parameters. Returns true for a valid job, or false otherwise: + // -if output quaternion pointer is NULL + bool Validate() const; + + // Runs job's execution task. + // The job is validated before any operation is performed, see Validate() for + // more details. + // Returns false if *this job is not valid. + bool Run() const; + + // Job input. + + // Target position to aim at, in model-space + Point3 target; + + // Joint forward axis, in joint local-space, to be aimed at target position. + // This vector shall be normalized, otherwise validation will fail. + // Default is x axis. + Vector3 forward; + + // Offset position from the joint in local-space, that will aim at target. + Vector3 offset; + + // Joint up axis, in joint local-space, used to keep the joint oriented in the + // same direction as the pole vector. Default is y axis. + Vector3 up; + + // Pole vector, in model-space. The pole vector defines the direction + // the up should point to. Note that IK chain orientation will flip when + // target vector and the pole vector are aligned/crossing each other. It's + // caller responsibility to ensure that this doesn't happen. + Vector3 pole_vector; + + // Twist_angle rotates joint around the target vector. + // Default is 0. + float twist_angle; + + // Weight given to the IK correction clamped in range [0,1]. This allows to + // blend / interpolate from no IK applied (0 weight) to full IK (1). + float weight; + + // Joint model-space matrix. + const Matrix4* joint; + + // Job output. + + // Output local-space joint correction quaternion. It needs to be multiplied + // with joint local-space quaternion. + Quat* joint_correction; + + // Optional boolean output value, set to true if target can be reached with IK + // computations. Target is considered not reachable when target is between + // joint and offset position. + bool* reached; +}; +} // namespace animation +} // namespace ozz +#endif // OZZ_OZZ_ANIMATION_RUNTIME_IK_AIM_JOB_H_ diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_two_bone_job.h b/Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_two_bone_job.h new file mode 100644 index 0000000000..8ddeba3eb7 --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_two_bone_job.h @@ -0,0 +1,123 @@ +//----------------------------------------------------------------------------// +// // +// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation // +// and distributed under the MIT License (MIT). // +// // +// Copyright (c) 2019 Guillaume Blanc // +// // +// Permission is hereby granted, free of charge, to any person obtaining a // +// copy of this software and associated documentation files (the "Software"), // +// to deal in the Software without restriction, including without limitation // +// the rights to use, copy, modify, merge, publish, distribute, sublicense, // +// and/or sell copies of the Software, and to permit persons to whom the // +// Software is furnished to do so, subject to the following conditions: // +// // +// The above copyright notice and this permission notice shall be included in // +// all copies or substantial portions of the Software. // +// // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // +// DEALINGS IN THE SOFTWARE. // +// // +//----------------------------------------------------------------------------// + +#ifndef OZZ_OZZ_ANIMATION_RUNTIME_IK_TWO_BONE_JOB_H_ +#define OZZ_OZZ_ANIMATION_RUNTIME_IK_TWO_BONE_JOB_H_ + +#include "../../base/platform.h" + +#include "../../../../../../../../Common_3/OS/Math/MathTypes.h" + +namespace ozz { +namespace animation { + +// ozz::animation::IKTwoBoneJob performs inverse kinematic on a three joints +// chain (two bones). +// The job computes the transformations (rotations) that needs to be applied to +// the first two joints of the chain (named start and middle joints) such that +// the third joint (named end) reaches the provided target position (if +// possible). The job outputs start and middle joint rotation corrections as +// quaternions. +// The three joints must be ancestors, but don't need to be direct +// ancestors (joints in-between will simply remain fixed). +// Implementation is inspired by Autodesk Maya 2 bone IK, improved stability +// wise and extended with Soften IK. +struct IKTwoBoneJob { + // Constructor, initializes default values. + IKTwoBoneJob(); + + // Validates job parameters. Returns true for a valid job, or false otherwise: + // -if any input pointer is NULL + // -if mid_axis isn't normalized. + bool Validate() const; + + // Runs job's execution task. + // The job is validated before any operation is performed, see Validate() for + // more details. + // Returns false if *this job is not valid. + bool Run() const; + + // Job input. + + // Target IK position, in model-space. This is the position the end of the + // joint chain will try to reach. + Point3 target; + + // Normalized middle joint rotation axis, in middle joint local-space. Default + // value is z axis. This axis is usually fixed for a given skeleton (as it's + // in middle joint space). Its direction is defined like this: a positive + // rotation around this axis will open the angle between the two bones. This + // in turn also to define which side the two joints must bend. Job validation + // will fail if mid_axis isn't normalized. + Vector3 mid_axis; + + // Pole vector, in model-space. The pole vector defines the direction the + // middle joint should point to, allowing to control IK chain orientation. + // Note that IK chain orientation will flip when target vector and the pole + // vector are aligned/crossing each other. It's caller responsibility to + // ensure that this doesn't happen. + Vector3 pole_vector; + + // Twist_angle rotates IK chain around the vector define by start-to-target + // vector. Default is 0. + float twist_angle; + + // Soften ratio allows the chain to gradually fall behind the target + // position. This prevents the joint chain from snapping into the final + // position, softening the final degrees before the joint chain becomes flat. + // This ratio represents the distance to the end, from which softening is + // starting. + float soften; + + // Weight given to the IK correction clamped in range [0,1]. This allows to + // blend / interpolate from no IK applied (0 weight) to full IK (1). + float weight; + + // Model-space matrices of the start, middle and end joints of the chain. + // The 3 joints should be ancestors. They don't need to be direct + // ancestors though. + const Matrix4* start_joint; + const Matrix4* mid_joint; + const Matrix4* end_joint; + + // Job output. + + // Local-space corrections to apply to start and middle joints in order for + // end joint to reach target position. + // These quaternions must be multiplied to the local-space quaternion of their + // respective joints. + Quat* start_joint_correction; + Quat* mid_joint_correction; + + // Optional boolean output value, set to true if target can be reached with IK + // computations. Reachability is driven by bone chain length, soften ratio and + // target distance. Target is considered unreached if weight is less than 1. + bool* reached; +}; +} // namespace animation +} // namespace ozz +#endif // OZZ_OZZ_ANIMATION_RUNTIME_IK_TWO_BONE_JOB_H_ diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/src/animation/runtime/ik_aim_job.cc b/Common_3/ThirdParty/OpenSource/ozz-animation/src/animation/runtime/ik_aim_job.cc new file mode 100644 index 0000000000..989dd62493 --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/src/animation/runtime/ik_aim_job.cc @@ -0,0 +1,207 @@ +//----------------------------------------------------------------------------// +// // +// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation // +// and distributed under the MIT License (MIT). // +// // +// Copyright (c) 2019 Guillaume Blanc // +// // +// Permission is hereby granted, free of charge, to any person obtaining a // +// copy of this software and associated documentation files (the "Software"), // +// to deal in the Software without restriction, including without limitation // +// the rights to use, copy, modify, merge, publish, distribute, sublicense, // +// and/or sell copies of the Software, and to permit persons to whom the // +// Software is furnished to do so, subject to the following conditions: // +// // +// The above copyright notice and this permission notice shall be included in // +// all copies or substantial portions of the Software. // +// // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // +// DEALINGS IN THE SOFTWARE. // +// // +//----------------------------------------------------------------------------// + +#include "../../../include/ozz/animation/runtime/ik_aim_job.h" + +using namespace ozz::math; + +namespace ozz { +namespace animation { +IKAimJob::IKAimJob() + : target(0.0f), + forward(Vector3::xAxis()), + offset(0.0f), + up(Vector3::yAxis()), + pole_vector(Vector3::yAxis()), + twist_angle(0.f), + weight(1.f), + joint(NULL), + joint_correction(NULL), + reached(NULL) {} + +bool IKAimJob::Validate() const { + bool valid = true; + valid &= joint != NULL; + valid &= joint_correction != NULL; + valid &= isNormalizedEst(forward); + return valid; +} + +namespace { + +// When there's an offset, the forward vector needs to be recomputed. +// The idea is to find the vector that will allow the point at offset position +// to aim at target position. This vector starts at joint position. It ends on a +// line perpendicular to pivot-offset line, at the intersection with the sphere +// defined by target position (centered on joint position). See geogebra +// diagram: media/doc/src/ik_aim_offset.ggb +bool ComputeOffsettedForward(Vector3 _forward, Vector3 _offset, + Vector3 _target, + Vector3* _offsetted_forward) { + // AO is projected offset vector onto the normalized forward vector. + //assert(ozz::math::AreAllTrue1(ozz::math::IsNormalizedEst3(_forward))); + const FloatInVec AOl = dot(_forward, _offset); + + // Compute square length of ac using Pythagorean theorem. + const FloatInVec ACl2 = lengthSqr(_offset) - AOl * AOl; + + // Square length of target vector, aka circle radius. + const FloatInVec r2 = lengthSqr(_target); + + // If offset is outside of the sphere defined by target length, the target + // isn't reachable. + if (ACl2 > r2) { + return false; + } + + // AIl is the length of the vector from offset to sphere intersection. + const FloatInVec AIl = sqrt(r2 - ACl2); + + // The distance from offset position to the intersection with the sphere is + // (AIl - AOl) Intersection point on the sphere can thus be computed. + *_offsetted_forward = _offset + _forward * (AIl - AOl); + + return true; +} +} // namespace + +bool IKAimJob::Run() const { + if (!Validate()) { + return false; + } + const FloatInVec zero(0.0f); + + // If matrices aren't invertible, they'll be all 0 (ozz::math + // implementation), which will result in identity correction quaternions. + const Matrix4 inv_joint = inverse(*joint); + + // Computes joint to target vector, in joint local-space (_js). + const Vector3 joint_to_target_js = (inv_joint * target).getXYZ(); + const FloatInVec joint_to_target_js_len2 = lengthSqr(joint_to_target_js); + + // Recomputes forward vector to account for offset. + // If the offset is further than target, it won't be reachable. + Vector3 offsetted_forward; + bool lreached = ComputeOffsettedForward(forward, offset, joint_to_target_js, + &offsetted_forward); + // Copies reachability result. + // If offsetted forward vector doesn't exists, target position cannot be + // aimed. + if (reached != NULL) { + *reached = lreached; + } + + if (!lreached || (joint_to_target_js_len2 == zero )) { + // Target can't be reached or is too close to joint position to find a + // direction. + *joint_correction = Quat::identity(); + return true; + } + + // Calculates joint_to_target_rot_ss quaternion which solves for + // offsetted_forward vector rotating onto the target. + const Quat joint_to_target_rot_js = + Quat::fromVectors(offsetted_forward, joint_to_target_js); + + // Calculates rotate_plane_js quaternion which aligns joint up to the pole + // vector. + const Vector3 corrected_up_js = + rotate(joint_to_target_rot_js, up); + + // Compute (and normalize) reference and pole planes normals. + const Vector3 pole_vector_js = (inv_joint * pole_vector).getXYZ(); + const Vector3 ref_joint_normal_js = + cross(pole_vector_js, joint_to_target_js); + const Vector3 joint_normal_js = + cross(corrected_up_js, joint_to_target_js); + const FloatInVec ref_joint_normal_js_len2 = lengthSqr(ref_joint_normal_js); + const FloatInVec joint_normal_js_len2 = lengthSqr(joint_normal_js); + + const Vector4 denoms(joint_to_target_js_len2, joint_normal_js_len2, + ref_joint_normal_js_len2, zero); + + Vector3 rotate_plane_axis_js; + Quat rotate_plane_js; + // Computing rotation axis and plane requires valid normals. + if (AreAllTrue3(cmpNotEq(denoms, Vector4(zero)))) { + const Vector4 rsqrts = rSqrtEstNR(denoms); + + // Computes rotation axis, which is either joint_to_target_js or + // -joint_to_target_js depending on rotation direction. + rotate_plane_axis_js = joint_to_target_js * rsqrts.getX(); + + // Computes angle cosine between the 2 normalized plane normals. + const FloatInVec rotate_plane_cos_angle = dot( + joint_normal_js * rsqrts.getY(), ref_joint_normal_js * rsqrts.getZ()); + const FloatInVec axis_flip = + andPerElem(dot(ref_joint_normal_js, corrected_up_js), + vector4int::mask_sign()); + const Vector3 rotate_plane_axis_flipped_js = + xorPerElem(rotate_plane_axis_js, axis_flip); + + // Builds quaternion along rotation axis. + const FloatInVec one(1.0f); + rotate_plane_js = Quat::fromAxisCosAngle( + rotate_plane_axis_flipped_js, clamp(-one, rotate_plane_cos_angle, one)); + } else { + rotate_plane_axis_js = joint_to_target_js * rSqrtEstNR(denoms.getX()); + rotate_plane_js = Quat::identity(); + } + + // Twists rotation plane. + Quat twisted; + if (twist_angle != 0.f) { + // If a twist angle is provided, rotation angle is rotated around joint to + // target vector. + const Quat twist_ss = Quat::rotation(twist_angle, rotate_plane_axis_js); + twisted = twist_ss * rotate_plane_js * joint_to_target_rot_js; + } else { + twisted = rotate_plane_js * joint_to_target_rot_js; + } + + // Weights output quaternion. + + // Fix up quaternions so w is always positive, which is required for NLerp + // (with identity quaternion) to lerp the shortest path. + const Vector4 twisted_fu = + xorPerElem(Vector4(twisted), And(vector4int::mask_sign(), + twisted.getW() < zero)); + + if (weight < 1.f) { + // NLerp start and mid joint rotations. + const Vector4 identity = Vector4::wAxis(); + const FloatInVec simd_weight = max(zero, FloatInVec(weight)); + *joint_correction = + Quat(normalize(lerp(simd_weight, identity, twisted_fu))); + } else { + // Quaternion doesn't need interpolation + *joint_correction = Quat(twisted_fu); + } + return true; +} +} // namespace animation +} // namespace ozz diff --git a/Common_3/ThirdParty/OpenSource/ozz-animation/src/animation/runtime/ik_two_bone_job.cc b/Common_3/ThirdParty/OpenSource/ozz-animation/src/animation/runtime/ik_two_bone_job.cc new file mode 100644 index 0000000000..4c4d728125 --- /dev/null +++ b/Common_3/ThirdParty/OpenSource/ozz-animation/src/animation/runtime/ik_two_bone_job.cc @@ -0,0 +1,387 @@ +//----------------------------------------------------------------------------// +// // +// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation // +// and distributed under the MIT License (MIT). // +// // +// Copyright (c) 2019 Guillaume Blanc // +// // +// Permission is hereby granted, free of charge, to any person obtaining a // +// copy of this software and associated documentation files (the "Software"), // +// to deal in the Software without restriction, including without limitation // +// the rights to use, copy, modify, merge, publish, distribute, sublicense, // +// and/or sell copies of the Software, and to permit persons to whom the // +// Software is furnished to do so, subject to the following conditions: // +// // +// The above copyright notice and this permission notice shall be included in // +// all copies or substantial portions of the Software. // +// // +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL // +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // +// DEALINGS IN THE SOFTWARE. // +// // +//----------------------------------------------------------------------------// + +#include "../../../include/ozz/animation/runtime/ik_two_bone_job.h" + +#include "../../../../../Common_3/OS/Interfaces/ILog.h" + +namespace ozz { +namespace animation { +IKTwoBoneJob::IKTwoBoneJob() + : target(0.0f), + mid_axis(Vector3::zAxis()), + pole_vector(Vector3::yAxis()), + twist_angle(0.f), + soften(1.f), + weight(1.f), + start_joint(NULL), + mid_joint(NULL), + end_joint(NULL), + start_joint_correction(NULL), + mid_joint_correction(NULL), + reached(NULL) {} + +bool IKTwoBoneJob::Validate() const { + bool valid = true; + valid &= start_joint && mid_joint && end_joint; + valid &= start_joint_correction && mid_joint_correction; + valid &= isNormalizedEst(mid_axis); + return valid; +} + +namespace { + +// Local data structure used to share constant data accross ik stages. +struct IKConstantSetup { + IKConstantSetup(const IKTwoBoneJob& _job) { + // Prepares constants + one = Vector4::one(); + mask_sign = vector4int::mask_sign(); + m_one = xorPerElem(one, mask_sign); + + // Computes inverse matrices required to change to start and mid spaces. + // If matrices aren't invertible, they'll be all 0 (ozz::math + // implementation), which will result in identity correction quaternions. + inv_start_joint = inverse(*_job.start_joint); + const Matrix4 inv_mid_joint = inverse(*_job.mid_joint); + + // Transform some positions to mid joint space (_ms) + const Vector3 start_ms = + (inv_mid_joint * Point3(_job.start_joint->getCol3().get128())).getXYZ(); + const Vector3 end_ms = + (inv_mid_joint * Point3(_job.end_joint->getCol3().get128())).getXYZ(); + + // Transform some positions to start joint space (_ss) + const Vector3 mid_ss = + (inv_start_joint * Point3(_job.mid_joint->getCol3().get128())).getXYZ(); + const Vector3 end_ss = + (inv_start_joint * Point3(_job.end_joint->getCol3().get128())).getXYZ(); + + // Computes bones vectors and length in mid and start spaces. + // Start joint position will be treated as 0 because all joints are + // expressed in start joint space. + start_mid_ms = -start_ms; + mid_end_ms = end_ms; + start_mid_ss = mid_ss; + const Vector3 mid_end_ss = end_ss - mid_ss; + const Vector3 start_end_ss = end_ss; + start_mid_ss_len2 = lengthSqr(start_mid_ss); + mid_end_ss_len2 = lengthSqr(mid_end_ss); + start_end_ss_len2 = lengthSqr(start_end_ss); + } + + // Constants + Vector4 one; + Vector4 m_one; + Vector4Int mask_sign; + + // Inverse matrices + Matrix4 inv_start_joint; + + // Bones vectors and length in mid and start spaces (_ms and _ss). + Vector3 start_mid_ms; + Vector3 mid_end_ms; + Vector3 start_mid_ss; + FloatInVec start_mid_ss_len2; + FloatInVec mid_end_ss_len2; + FloatInVec start_end_ss_len2; +}; + +// Smoothen target position when it's further that a ratio of the joint chain +// length, and start to target length isn't 0. +// Inspired by http://www.softimageblog.com/archives/108 +// and http://www.ryanjuckett.com/programming/analytic-two-bone-ik-in-2d/ +bool SoftenTarget(const IKTwoBoneJob& _job, const IKConstantSetup& _setup, + Vector3* _start_target_ss, + FloatInVec* _start_target_ss_len2) { + // Hanlde position in start joint space (_ss) + const Vector3 start_target_original_ss = + (_setup.inv_start_joint * _job.target).getXYZ(); + const FloatInVec start_target_original_ss_len2 = + lengthSqr(start_target_original_ss); + const Vector3 lengths = + sqrtPerElem(Vector3(_setup.start_mid_ss_len2, _setup.mid_end_ss_len2, + start_target_original_ss_len2)); + const FloatInVec start_mid_ss_len = lengths.getX(); + const FloatInVec mid_end_ss_len = lengths.getY(); + const FloatInVec start_target_original_ss_len = lengths.getZ(); + const FloatInVec bone_len_diff_abs = + andNotPerElem(start_mid_ss_len - mid_end_ss_len, _setup.mask_sign); + const FloatInVec bones_chain_len = start_mid_ss_len + mid_end_ss_len; + const Vector4 da = + bones_chain_len * clamp(Vector4::zero(), + Vector4(_job.soften, 0.0f, 0.0f, 0.0f), + _setup.one); + const FloatInVec ds = bones_chain_len - da.getX(); + + // Sotftens target position if it is further than a ratio (_soften) of the + // whole bone chain length. Needs to check also that ds and + // start_target_original_ss_len2 are != 0, because they're used as a + // denominator. + // x = start_target_original_ss_len > da + // y = start_target_original_ss_len > 0 + // z = start_target_original_ss_len > bone_len_diff_abs + // w = ds > 0 + Vector4 left(start_target_original_ss_len); + left.setW(ds); + Vector4 right(da); + right.setZ(bone_len_diff_abs); + const Vector4Int comp = cmpGt(left, right); + const int comp_mask = MoveMask(comp); + + // xyw all 1, z is untested. + if ((comp_mask & 0xb) == 0xb) { + // Finds interpolation ratio (aka alpha). + const FloatInVec alpha = (start_target_original_ss_len - da.getX()) * rcpEst(ds); + // Approximate an exponential function with : 1-(3^4)/(alpha+3)^4 + // The derivative must be 1 for x = 0, and y must never exceeds 1. + // Negative x aren't used. + const FloatInVec three(3.f); + Vector4 op(three); + op.setY(alpha + three); + const Vector4 op2 = mulPerElem(op, op); + const Vector4 op4 = mulPerElem(op2, op2); + const FloatInVec ratio = op4.getX() * rcpEst(op4.getY()); + + // Recomputes start_target_ss vector and length. + const FloatInVec start_target_ss_len = da.getX() + ds - ds * ratio; + *_start_target_ss_len2 = start_target_ss_len * start_target_ss_len; + *_start_target_ss = + start_target_original_ss * + (start_target_ss_len * rcpEst(start_target_original_ss_len)); + } else { + *_start_target_ss = start_target_original_ss; + *_start_target_ss_len2 = start_target_original_ss_len2; + } + + // The maximum distance we can reach is the soften bone chain length: da + // (stored in !x). The minimum distance we can reach is the absolute value of + // the difference of the 2 bone lengths, |d1−d2| (stored in z). x is 0 and z + // is 1, yw are untested. + return (comp_mask & 0x5) == 0x4; +} + +Quat ComputeMidJoint(const IKTwoBoneJob& _job, + const IKConstantSetup& _setup, + const FloatInVec _start_target_ss_len2) { + // Computes expected angle at mid_ss joint, using law of cosine (generalized + // Pythagorean). + // c^2 = a^2 + b^2 - 2ab cosC + // cosC = (a^2 + b^2 - c^2) / 2ab + // Computes both corrected and initial mid joint angles + // cosine within a single SimdFloat4 (corrected is x component, initial is y). + const Vector4 start_mid_end_sum_ss_len2( + _setup.start_mid_ss_len2 + _setup.mid_end_ss_len2); + const Vector4 start_mid_end_ss_half_rlen( + FloatInVec(.5f) * + rSqrtEstNR(_setup.start_mid_ss_len2 * _setup.mid_end_ss_len2)); + // Cos value needs to be clamped, as it will exit expected range if + // start_target_ss_len2 is longer than the triangle can be (start_mid_ss + + // mid_end_ss). + const Vector4 mid_cos_angles_unclamped = + mulPerElem( (start_mid_end_sum_ss_len2 - + Vector4(_start_target_ss_len2).setY(_setup.start_end_ss_len2)), + start_mid_end_ss_half_rlen); + const Vector4 mid_cos_angles = + clamp(_setup.m_one, mid_cos_angles_unclamped, _setup.one); + + // Computes corrected angle + const Vector4 mid_angles = aCos(mid_cos_angles); + const FloatInVec mid_corrected_angle = mid_angles.getX(); + + // Computes initial angle. + // The sign of this angle needs to be decided. It's considered negative if + // mid-to-end joint is bent backward (mid_axis direction dictates valid + // bent direction). + const Vector3 bent_side_ref = cross(_setup.start_mid_ms, _job.mid_axis); + const BoolInVec bent_side_flip = + dot(bent_side_ref, _setup.mid_end_ms) < FloatInVec(0.0f); + const FloatInVec mid_initial_angle = xorPerElem(mid_angles.getY(), + (bent_side_flip & _setup.mask_sign)); + + // Finally deduces initial to corrected angle difference. + const FloatInVec mid_angles_diff = mid_corrected_angle - mid_initial_angle; + + // Builds queternion. + return Quat::rotation(mid_angles_diff, _job.mid_axis); +} + +Quat ComputeStartJoint(const IKTwoBoneJob& _job, const IKConstantSetup& _setup, + const Quat& _mid_rot_ms, const Vector3 _start_target_ss, + const FloatInVec _start_target_ss_len2) { + // Pole vector in start joint space (_ss) + const Vector3 pole_ss = (_setup.inv_start_joint * _job.pole_vector).getXYZ(); + + // start_mid_ss with quaternion mid_rot_ms applied. + const Vector3 mid_end_ss_final = + (_setup.inv_start_joint * + (*_job.mid_joint * rotate(_mid_rot_ms, _setup.mid_end_ms))).getXYZ(); + const Vector3 start_end_ss_final = _setup.start_mid_ss + mid_end_ss_final; + + // Quaternion for rotating the effector onto the target + const Quat end_to_target_rot_ss = + Quat::fromVectors(start_end_ss_final, _start_target_ss); + + // Calculates rotate_plane_ss quaternion which aligns joint chain plane to + // the reference plane (pole vector). This can only be computed if start + // target axis is valid (not 0 length) + // ------------------------------------------------- + Quat start_rot_ss = end_to_target_rot_ss; + if (_start_target_ss_len2 > FloatInVec(0.0f)) { + // Computes each plane normal. + const Vector3 ref_plane_normal_ss = + cross(_start_target_ss, pole_ss); + const FloatInVec ref_plane_normal_ss_len2 = + lengthSqr(ref_plane_normal_ss); + // Computes joint chain plane normal, which is the same as mid joint axis + // (same triangle). + const Vector3 mid_axis_ss = + (_setup.inv_start_joint * + (*_job.mid_joint * _job.mid_axis)).getXYZ(); + const Vector3 joint_plane_normal_ss = + rotate(end_to_target_rot_ss,mid_axis_ss); + const FloatInVec joint_plane_normal_ss_len2 = + lengthSqr(joint_plane_normal_ss); + // Computes all reciprocal square roots at once. + const Vector3 rsqrts = + rSqrtEstNR(Vector3(_start_target_ss_len2, ref_plane_normal_ss_len2, + joint_plane_normal_ss_len2)); + + // Computes angle cosine between the 2 normalized normals. + const Vector4 rotate_plane_cos_angle( + dot(ref_plane_normal_ss * rsqrts.getY(), + joint_plane_normal_ss * rsqrts.getZ())); + + // Computes rotation axis, which is either start_target_ss or + // -start_target_ss depending on rotation direction. + const Vector3 rotate_plane_axis_ss = _start_target_ss * rsqrts.getX(); + const FloatInVec start_axis_flip = + andPerElem(dot(joint_plane_normal_ss, pole_ss), _setup.mask_sign); + const Vector3 rotate_plane_axis_flipped_ss = + xorPerElem(rotate_plane_axis_ss, start_axis_flip); + + // Builds quaternion along rotation axis. + const Quat rotate_plane_ss = Quat::fromAxisCosAngle( + rotate_plane_axis_flipped_ss, + clamp(_setup.m_one, rotate_plane_cos_angle, _setup.one).getX()); + + if (_job.twist_angle != 0.f) { + // If a twist angle is provided, rotation angle is rotated along + // rotation plane axis. + const Quat twist_ss = Quat::rotation(_job.twist_angle, rotate_plane_axis_ss ); + start_rot_ss = twist_ss * rotate_plane_ss * end_to_target_rot_ss; + } else { + start_rot_ss = rotate_plane_ss * end_to_target_rot_ss; + } + } + return start_rot_ss; +} + +void WeightOutput(const IKTwoBoneJob& _job, const IKConstantSetup& _setup, + const Quat& _start_rot, + const Quat& _mid_rot) { + const FloatInVec zero(0.0f); + + // Fix up quaternions so w is always positive, which is required for NLerp + // (with identity quaternion) to lerp the shortest path. + const Vector4 start_rot_fu = + xorPerElem(Vector4(_start_rot), + And(_setup.mask_sign, _start_rot.getW() < zero)); + const Vector4 mid_rot_fu = xorPerElem( + Vector4(_mid_rot), And(_setup.mask_sign, _mid_rot.getW() < zero)); + + if (_job.weight < 1.f) { + // NLerp start and mid joint rotations. + const Vector4 identity = Vector4::wAxis(); + const FloatInVec simd_weight = max(zero, FloatInVec(_job.weight)); + + // Lerp + const Vector4 start_lerp = lerp(simd_weight, identity, start_rot_fu); + const Vector4 mid_lerp = lerp(simd_weight, identity, mid_rot_fu); + + + Vector4 lengths(lengthSqr(start_lerp)); + lengths.setY(lengthSqr(mid_lerp)); + + // Normalize + const Vector4 rsqrts = rSqrtEstNR(lengths); + *_job.start_joint_correction = Quat(start_lerp * rsqrts.getX()); + *_job.mid_joint_correction = Quat(mid_lerp * rsqrts.getY()); + } else { + // Quatenions don't need interpolation + *_job.start_joint_correction = Quat(start_rot_fu); + *_job.mid_joint_correction = Quat(mid_rot_fu); + } +} +} // namespace + +bool IKTwoBoneJob::Run() const { + if (!Validate()) { + return false; + } + + // Early out if weight is 0. + if (weight <= 0.f) { + // No correction. + *start_joint_correction = *mid_joint_correction = + Quat::identity(); + // Target isn't reached. + if (reached) { + *reached = false; + } + return true; + } + + // Prepares constant ik data. + const IKConstantSetup setup(*this); + + // Finds soften target position. + Vector3 start_target_ss; + FloatInVec start_target_ss_len2; + const bool lreached = + SoftenTarget(*this, setup, &start_target_ss, &start_target_ss_len2); + if (reached) { + *reached = lreached && weight >= 1.f; + } + + // Calculate mid_rot_local quaternion which solves for the mid_ss joint + // rotation. + const Quat mid_rot_ms = + ComputeMidJoint(*this, setup, start_target_ss_len2); + + // Calculates end_to_target_rot_ss quaternion which solves for effector + // rotating onto the target. + const Quat start_rot_ss = ComputeStartJoint( + *this, setup, mid_rot_ms, start_target_ss, start_target_ss_len2); + + // Finally apply weight and output quaternions. + WeightOutput(*this, setup, start_rot_ss, mid_rot_ms); + + return true; +} +} // namespace animation +} // namespace ozz diff --git a/Common_3/ThirdParty/OpenSource/tinydds/tinydds.h b/Common_3/ThirdParty/OpenSource/tinydds/tinydds.h index 69d7474075..5bc33b5901 100644 --- a/Common_3/ThirdParty/OpenSource/tinydds/tinydds.h +++ b/Common_3/ThirdParty/OpenSource/tinydds/tinydds.h @@ -894,7 +894,7 @@ void TinyDDS_Reset(TinyDDS_ContextHandle handle) { } } - if(ctx->clut) { + if (ctx->clut) { callbacks.freeFn(user, (void *) ctx->clut); ctx->clut = NULL; } @@ -908,10 +908,9 @@ void TinyDDS_Reset(TinyDDS_ContextHandle handle) { static bool TinyDDS_IsCLUT(TinyDDS_Format fmt) { switch (fmt) { - case TDDS_P8: - case TDDS_A8P8: - return true; - default: return false; + case TDDS_P8: + case TDDS_A8P8: return true; + default: return false; } } @@ -1069,26 +1068,23 @@ static uint32_t TinyDDS_FormatSize(TinyDDS_Format fmt) { // 4 * 32 bits case TDDS_R32G32B32A32_UINT: case TDDS_R32G32B32A32_SINT: - case TDDS_R32G32B32A32_SFLOAT: - return 16; - // block formats - case TDDS_BC1_RGBA_UNORM_BLOCK: - case TDDS_BC1_RGBA_SRGB_BLOCK: - case TDDS_BC4_UNORM_BLOCK: - case TDDS_BC4_SNORM_BLOCK: - return 8; - - case TDDS_BC2_UNORM_BLOCK: - case TDDS_BC2_SRGB_BLOCK: - case TDDS_BC3_UNORM_BLOCK: - case TDDS_BC3_SRGB_BLOCK: - case TDDS_BC5_UNORM_BLOCK: - case TDDS_BC5_SNORM_BLOCK: - case TDDS_BC6H_UFLOAT_BLOCK: - case TDDS_BC6H_SFLOAT_BLOCK: - case TDDS_BC7_UNORM_BLOCK: - case TDDS_BC7_SRGB_BLOCK: - return 16; + case TDDS_R32G32B32A32_SFLOAT: return 16; + // block formats + case TDDS_BC1_RGBA_UNORM_BLOCK: + case TDDS_BC1_RGBA_SRGB_BLOCK: + case TDDS_BC4_UNORM_BLOCK: + case TDDS_BC4_SNORM_BLOCK: return 8; + + case TDDS_BC2_UNORM_BLOCK: + case TDDS_BC2_SRGB_BLOCK: + case TDDS_BC3_UNORM_BLOCK: + case TDDS_BC3_SRGB_BLOCK: + case TDDS_BC5_UNORM_BLOCK: + case TDDS_BC5_SNORM_BLOCK: + case TDDS_BC6H_UFLOAT_BLOCK: + case TDDS_BC6H_SFLOAT_BLOCK: + case TDDS_BC7_UNORM_BLOCK: + case TDDS_BC7_SRGB_BLOCK: return 16; case TDDS_UNDEFINED: return 0; // default: return 0; @@ -1339,7 +1335,11 @@ bool TinyDDS_ReadHeader(TinyDDS_ContextHandle handle) { ctx->headerPos = ctx->callbacks.tellFn(ctx->user); if( ctx->callbacks.readFn(ctx->user, &ctx->header, sizeof(TinyDDS_Header)) != sizeof(TinyDDS_Header)) { - ctx->callbacks.errorFn(ctx->user, "Could not read DDS header"); + ctx->callbacks.errorFn(ctx->user, "Count not read DDS header"); + return false; + } + + if (ctx->header.magic != 0x20534444) { return false; } @@ -1396,15 +1396,17 @@ bool TinyDDS_ReadHeader(TinyDDS_ContextHandle handle) { if(ctx->header.mipMapCount == 0) ctx->header.mipMapCount = 1; } - if(TinyDDS_IsCLUT(ctx->format)) { + if (TinyDDS_IsCLUT(ctx->format)) { // for now don't ask to generate mipmaps for cluts - if(ctx->header.mipMapCount == 0) ctx->header.mipMapCount = 1; + if (ctx->header.mipMapCount == 0) { + ctx->header.mipMapCount = 1; + } size_t const clutSize = 256 * sizeof(uint32_t); - ctx->clut = (uint32_t*) ctx->callbacks.allocFn(ctx->user, clutSize); + ctx->clut = (uint32_t *) ctx->callbacks.allocFn(ctx->user, clutSize); - if( ctx->callbacks.readFn(ctx->user, (void*)ctx->clut, clutSize) != clutSize) { + if (ctx->callbacks.readFn(ctx->user, (void *) ctx->clut, clutSize) != clutSize) { ctx->callbacks.errorFn(ctx->user, "Could not read DDS CLUT"); return false; } diff --git a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_apis.h b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_apis.h index 82d6b1acf8..cbce5e919f 100644 --- a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_apis.h +++ b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_apis.h @@ -1,4 +1,4 @@ -// Auto generated by formatgen on Sep 6 2019 +// Auto generated by formatgen on Sep 21 2019 #pragma once #if !defined(TINYIMAGEFORMAT_APIS_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) #define TINYIMAGEFORMAT_APIS_H_ 1 @@ -1044,16 +1044,11 @@ inline TinyImageFormat_DXGI_FORMAT TinyImageFormat_DXGI_FORMATToTypeless(TinyIma case TIF_DXGI_FORMAT_R16G16_SNORM: case TIF_DXGI_FORMAT_R16G16_SINT: return TIF_DXGI_FORMAT_R16G16_TYPELESS; - case TIF_DXGI_FORMAT_R9G9B9E5_SHAREDEXP: + case TIF_DXGI_FORMAT_R9G9B9E5_SHAREDEXP: case TIF_DXGI_FORMAT_D32_FLOAT: case TIF_DXGI_FORMAT_R32_FLOAT: case TIF_DXGI_FORMAT_R32_UINT: case TIF_DXGI_FORMAT_R32_SINT: return TIF_DXGI_FORMAT_R32_TYPELESS; - - // This is not working - //case TIF_DXGI_FORMAT_R11G11B10_FLOAT: // closest typeless is raw 32 bits - case TIF_DXGI_FORMAT_R11G11B10_FLOAT: return TIF_DXGI_FORMAT_R11G11B10_FLOAT; - case TIF_DXGI_FORMAT_R8G8_UNORM: case TIF_DXGI_FORMAT_R8G8_UINT: case TIF_DXGI_FORMAT_R8G8_SNORM: @@ -1084,13 +1079,13 @@ inline TinyImageFormat_DXGI_FORMAT TinyImageFormat_DXGI_FORMATToTypeless(TinyIma case TIF_DXGI_FORMAT_B5G6R5_UNORM: case TIF_DXGI_FORMAT_B5G5R5A1_UNORM: return TIF_DXGI_FORMAT_R16_TYPELESS; + case TIF_DXGI_FORMAT_R11G11B10_FLOAT: return TIF_DXGI_FORMAT_R11G11B10_FLOAT; + case TIF_DXGI_FORMAT_B8G8R8X8_UNORM: - case TIF_DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: - return TIF_DXGI_FORMAT_B8G8R8X8_TYPELESS; + case TIF_DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: return TIF_DXGI_FORMAT_B8G8R8X8_TYPELESS; case TIF_DXGI_FORMAT_B8G8R8A8_UNORM: - case TIF_DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: - return TIF_DXGI_FORMAT_B8G8R8A8_TYPELESS; + case TIF_DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: return TIF_DXGI_FORMAT_B8G8R8A8_TYPELESS; case TIF_DXGI_FORMAT_BC6H_UF16: case TIF_DXGI_FORMAT_BC6H_SF16: return TIF_DXGI_FORMAT_BC6H_TYPELESS; @@ -1344,15 +1339,7 @@ inline TinyImageFormat_MTLPixelFormat TinyImageFormat_ToMTLPixelFormat(TinyImage case TinyImageFormat_R32G32B32A32_SFLOAT: return TIF_MTLPixelFormatRGBA32Float; case TinyImageFormat_B10G11R11_UFLOAT: return TIF_MTLPixelFormatRG11B10Float; case TinyImageFormat_E5B9G9R9_UFLOAT: return TIF_MTLPixelFormatRGB9E5Float; -#ifdef TARGET_IOS - case TinyImageFormat_D16_UNORM: - if (@available(iOS 13, *)) - return TIF_MTLPixelFormatDepth16Unorm; - else - return TIF_MTLPixelFormatDepth32Float; -#else case TinyImageFormat_D16_UNORM: return TIF_MTLPixelFormatDepth16Unorm; -#endif case TinyImageFormat_X8_D24_UNORM: return TIF_MTLPixelFormatDepth24Unorm_Stencil8; case TinyImageFormat_D32_SFLOAT: return TIF_MTLPixelFormatDepth32Float; case TinyImageFormat_S8_UINT: return TIF_MTLPixelFormatStencil8; diff --git a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_base.h b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_base.h index 09678bad9d..31ba9a58b7 100644 --- a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_base.h +++ b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_base.h @@ -1,4 +1,4 @@ -// Auto generated by formatgen on Sep 6 2019 +// Auto generated by formatgen on Sep 21 2019 #pragma once #if !defined(TINYIMAGEFORMAT_BASE_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) #define TINYIMAGEFORMAT_BASE_H_ 1 diff --git a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_decode.h b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_decode.h index bb90aec525..ce211c32ea 100644 --- a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_decode.h +++ b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_decode.h @@ -1,4 +1,4 @@ -// Auto generated by formatgen on Sep 6 2019 +// Auto generated by formatgen on Sep 21 2019 #pragma once #if !defined(TINYIMAGEFORMAT_DECODE_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) #define TINYIMAGEFORMAT_DECODE_H_ 1 diff --git a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_encode.h b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_encode.h index 490a812197..18d0a549f5 100644 --- a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_encode.h +++ b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_encode.h @@ -1,4 +1,4 @@ -// Auto generated by formatgen on Sep 6 2019 +// Auto generated by formatgen on Sep 21 2019 #pragma once #if !defined(TINYIMAGEFORMAT_ENCODE_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) #define TINYIMAGEFORMAT_ENCODE_H_ 1 diff --git a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_query.h b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_query.h index 895e6a7e8a..03ddc2ec49 100644 --- a/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_query.h +++ b/Common_3/ThirdParty/OpenSource/tinyimageformat/tinyimageformat_query.h @@ -1,4 +1,4 @@ -// Auto generated by formatgen on Sep 6 2019 +// Auto generated by formatgen on Sep 21 2019 #pragma once #if !defined(TINYIMAGEFORMAT_QUERY_H_) && !defined(TINYIMAGEFORMAT_IMAGEFORMAT_H) #define TINYIMAGEFORMAT_QUERY_H_ 1 @@ -289,6 +289,8 @@ TIF_CONSTEXPR inline bool TinyImageFormat_IsFloat(TinyImageFormat const fmt) { case TinyImageFormat_R64G64_SFLOAT: return true; case TinyImageFormat_R64G64B64_SFLOAT: return true; case TinyImageFormat_R64G64B64A64_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return true; case TinyImageFormat_DXBC6H_UFLOAT: return true; case TinyImageFormat_DXBC6H_SFLOAT: return true; default: return false; @@ -363,6 +365,10 @@ TIF_CONSTEXPR inline bool TinyImageFormat_IsNormalised(TinyImageFormat const fmt case TinyImageFormat_R16G16B16_SNORM: return true; case TinyImageFormat_R16G16B16A16_UNORM: return true; case TinyImageFormat_R16G16B16A16_SNORM: return true; + case TinyImageFormat_D16_UNORM: return true; + case TinyImageFormat_X8_D24_UNORM: return true; + case TinyImageFormat_D16_UNORM_S8_UINT: return true; + case TinyImageFormat_D24_UNORM_S8_UINT: return true; case TinyImageFormat_DXBC1_RGB_UNORM: return true; case TinyImageFormat_DXBC1_RGB_SRGB: return true; case TinyImageFormat_DXBC1_RGBA_UNORM: return true; @@ -483,6 +489,8 @@ TIF_CONSTEXPR inline bool TinyImageFormat_IsSigned(TinyImageFormat const fmt) { case TinyImageFormat_R64G64B64_SFLOAT: return true; case TinyImageFormat_R64G64B64A64_SINT: return true; case TinyImageFormat_R64G64B64A64_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT: return true; + case TinyImageFormat_D32_SFLOAT_S8_UINT: return true; case TinyImageFormat_DXBC4_SNORM: return true; case TinyImageFormat_DXBC5_SNORM: return true; case TinyImageFormat_DXBC6H_SFLOAT: return true; @@ -975,6 +983,16 @@ TIF_CONSTEXPR inline uint32_t TinyImageFormat_BitSizeOfBlock(TinyImageFormat con case TinyImageFormat_PVRTC1_4BPP_SRGB: return 64; case TinyImageFormat_PVRTC2_2BPP_SRGB: return 64; case TinyImageFormat_PVRTC2_4BPP_SRGB: return 64; + case TinyImageFormat_ETC2_R8G8B8_UNORM: return 64; + case TinyImageFormat_ETC2_R8G8B8_SRGB: return 64; + case TinyImageFormat_ETC2_R8G8B8A1_UNORM: return 64; + case TinyImageFormat_ETC2_R8G8B8A1_SRGB: return 64; + case TinyImageFormat_ETC2_R8G8B8A8_UNORM: return 64; + case TinyImageFormat_ETC2_R8G8B8A8_SRGB: return 64; + case TinyImageFormat_ETC2_EAC_R11_UNORM: return 64; + case TinyImageFormat_ETC2_EAC_R11_SNORM: return 64; + case TinyImageFormat_ETC2_EAC_R11G11_UNORM: return 64; + case TinyImageFormat_ETC2_EAC_R11G11_SNORM: return 64; case TinyImageFormat_ASTC_4x4_UNORM: return 128; case TinyImageFormat_ASTC_4x4_SRGB: return 128; case TinyImageFormat_ASTC_5x4_UNORM: return 128; diff --git a/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.sln b/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.sln index ca41235bdb..b54920aef4 100644 --- a/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.sln +++ b/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.sln @@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetPipeline", "AssetPipeline.vcxproj", "{86CCE738-AAA1-4327-9DE0-AAB5B23B7852}" ProjectSection(ProjectDependencies) = postProject {D89F2A05-407F-427F-BD64-B9AAC130E604} = {D89F2A05-407F-427F-BD64-B9AAC130E604} + {59586A07-8E7E-411D-BC3D-387E039AA423} = {59586A07-8E7E-411D-BC3D-387E039AA423} {AC91B515-5B5E-399D-BF31-B6272AF9D139} = {AC91B515-5B5E-399D-BF31-B6272AF9D139} {29449326-FEDE-40D1-B849-536BD8E58041} = {29449326-FEDE-40D1-B849-536BD8E58041} {30DD3D57-0026-48C8-BFD1-6392F319E23A} = {30DD3D57-0026-48C8-BFD1-6392F319E23A} @@ -36,6 +37,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetPipelineCmd", "AssetPi EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MeshOptimizer", "..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\MeshOptimizer.vcxproj", "{D89F2A05-407F-427F-BD64-B9AAC130E604}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basisu", "..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj", "{59586A07-8E7E-411D-BC3D-387E039AA423}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -318,35 +321,62 @@ Global {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseVk|x86.Build.0 = ReleaseVk|Win32 {D89F2A05-407F-427F-BD64-B9AAC130E604}.Debug|x64.ActiveCfg = DebugDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.Debug|x64.Build.0 = DebugDx11|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.Debug|x86.ActiveCfg = DebugDx11|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.Debug|x86.Build.0 = DebugDx11|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.Debug|x86.ActiveCfg = ReleaseDx11|x64 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.Debug|x86.Build.0 = ReleaseDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx|x64.ActiveCfg = DebugDx|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx|x64.Build.0 = DebugDx|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx|x86.ActiveCfg = DebugDx|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx11|x64.ActiveCfg = DebugDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx11|x64.Build.0 = DebugDx11|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx11|x86.ActiveCfg = DebugDx11|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx11|x86.Build.0 = DebugDx11|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugDx11|x86.ActiveCfg = DebugDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugVk|x64.ActiveCfg = DebugVk|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugVk|x64.Build.0 = DebugVk|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugVk|x86.ActiveCfg = DebugVk|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugVk|x86.Build.0 = DebugVk|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.DebugVk|x86.ActiveCfg = DebugVk|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.Release|x64.ActiveCfg = ReleaseVk|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.Release|x64.Build.0 = ReleaseVk|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.Release|x86.ActiveCfg = ReleaseDx|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.Release|x86.Build.0 = ReleaseDx|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.Release|x86.ActiveCfg = ReleaseDx11|x64 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.Release|x86.Build.0 = ReleaseDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx|x64.ActiveCfg = ReleaseDx|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx|x86.ActiveCfg = ReleaseDx|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx|x86.Build.0 = ReleaseDx|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx|x86.ActiveCfg = ReleaseDx|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx11|x64.ActiveCfg = ReleaseDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx11|x64.Build.0 = ReleaseDx11|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx11|x86.ActiveCfg = ReleaseDx11|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx11|x86.Build.0 = ReleaseDx11|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseDx11|x86.ActiveCfg = ReleaseDx11|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseVk|x64.Build.0 = ReleaseVk|x64 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseVk|x86.ActiveCfg = ReleaseVk|Win32 - {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseVk|x86.Build.0 = ReleaseVk|Win32 + {D89F2A05-407F-427F-BD64-B9AAC130E604}.ReleaseVk|x86.ActiveCfg = ReleaseVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x64.ActiveCfg = Debug|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x64.Build.0 = Debug|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x86.ActiveCfg = Debug|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Debug|x86.Build.0 = Debug|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x64.ActiveCfg = DebugDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x64.Build.0 = DebugDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x86.ActiveCfg = DebugDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x86.Build.0 = DebugDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x64.ActiveCfg = DebugDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x64.Build.0 = DebugDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x86.ActiveCfg = DebugDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x86.Build.0 = DebugDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x64.ActiveCfg = DebugVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x64.Build.0 = DebugVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x86.ActiveCfg = DebugVk|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x86.Build.0 = DebugVk|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x64.ActiveCfg = Release|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x64.Build.0 = Release|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x86.ActiveCfg = Release|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.Release|x86.Build.0 = Release|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x64.ActiveCfg = ReleaseDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x86.ActiveCfg = ReleaseDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x86.Build.0 = ReleaseDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x64.ActiveCfg = ReleaseDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x64.Build.0 = ReleaseDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x86.ActiveCfg = ReleaseDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x86.Build.0 = ReleaseDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x64.Build.0 = ReleaseVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x86.ActiveCfg = ReleaseVk|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x86.Build.0 = ReleaseVk|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.vcxproj b/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.vcxproj index 9e2ae82b36..f399467a9a 100644 --- a/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.vcxproj +++ b/Common_3/Tools/AssetPipeline/Win64/AssetPipeline.vcxproj @@ -166,7 +166,8 @@ vulkan-1.lib;%(AdditionalDependencies) - OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib + + %(AdditionalLibraryDirectories) @@ -195,7 +196,8 @@ vulkan-1.lib;%(AdditionalDependencies) - OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib + + %(AdditionalLibraryDirectories) @@ -224,7 +226,8 @@ vulkan-1.lib;%(AdditionalDependencies) - OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib + + %(AdditionalLibraryDirectories) @@ -258,7 +261,8 @@ vulkan-1.lib;%(AdditionalDependencies) - OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib + + %(AdditionalLibraryDirectories) @@ -292,7 +296,8 @@ vulkan-1.lib;%(AdditionalDependencies) - OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib + + %(AdditionalLibraryDirectories) @@ -326,7 +331,8 @@ vulkan-1.lib;%(AdditionalDependencies) - OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib + + %(AdditionalLibraryDirectories) diff --git a/Common_3/Tools/AssetPipeline/Win64/AssetPipelineCmd.vcxproj b/Common_3/Tools/AssetPipeline/Win64/AssetPipelineCmd.vcxproj index e01270e31d..6ea191f79c 100644 --- a/Common_3/Tools/AssetPipeline/Win64/AssetPipelineCmd.vcxproj +++ b/Common_3/Tools/AssetPipeline/Win64/AssetPipelineCmd.vcxproj @@ -193,24 +193,24 @@ true - $(IncludePath) + $(ProjectDir)..\..\..\ThirdParty\OpenSource\ozz-animation\include;$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\include;$(IncludePath); $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(OutDir);$(LibraryPath) - true + $(SolutionDir)\$(Platform)\$(Configuration);$(OutDir);$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\win64\Bin\Debug;$(ProjectDir)..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(ProjectDir)..\..\..\Tools\AssetLoader\Win64\x64\$(Configuration);$(LibraryPath); + false true - $(IncludePath) + $(ProjectDir)..\..\..\ThirdParty\OpenSource\ozz-animation\include;$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\include;$(IncludePath); $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(OutDir);$(LibraryPath) - true + $(SolutionDir)\$(Platform)\$(Configuration);$(OutDir);$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\win64\Bin\Debug;$(ProjectDir)..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(ProjectDir)..\..\..\Tools\AssetLoader\Win64\x64\$(Configuration);$(LibraryPath); + false true - $(IncludePath) + $(ProjectDir)..\..\..\ThirdParty\OpenSource\ozz-animation\include;$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\include;$(IncludePath); $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(OutDir);$(LibraryPath) - true + $(SolutionDir)\$(Platform)\$(Configuration);$(OutDir);$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\win64\Bin\Debug;$(ProjectDir)..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(ProjectDir)..\..\..\Tools\AssetLoader\Win64\x64\$(Configuration);$(LibraryPath); + false false @@ -223,24 +223,24 @@ false - $(IncludePath) + $(ProjectDir)..\..\..\ThirdParty\OpenSource\ozz-animation\include;$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\include;$(IncludePath); $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(OutDir);$(LibraryPath) - true + $(SolutionDir)\$(Platform)\$(Configuration);$(OutDir);$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\win64\Bin\Release;$(ProjectDir)..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(ProjectDir)..\..\..\Tools\AssetLoader\Win64\x64\$(Configuration);$(LibraryPath); + false false - $(IncludePath) + $(ProjectDir)..\..\..\ThirdParty\OpenSource\ozz-animation\include;$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\include;$(IncludePath); $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(OutDir);$(LibraryPath) - true + $(SolutionDir)\$(Platform)\$(Configuration);$(OutDir);$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\win64\Bin\Release;$(ProjectDir)..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(ProjectDir)..\..\..\Tools\AssetLoader\Win64\x64\$(Configuration);$(LibraryPath); + false false - $(IncludePath) + $(ProjectDir)..\..\..\ThirdParty\OpenSource\ozz-animation\include;$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\include;$(IncludePath); $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ - $(OutDir);$(LibraryPath) - true + $(SolutionDir)\$(Platform)\$(Configuration);$(OutDir);$(ProjectDir)..\..\..\ThirdParty\OpenSource\assimp\4.1.0\win64\Bin\Release;$(ProjectDir)..\..\..\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(ProjectDir)..\..\..\Tools\AssetLoader\Win64\x64\$(Configuration);$(LibraryPath); + false @@ -303,11 +303,12 @@ true + /FS %(AdditionalOptions) Console true - AssetPipeline.lib;%(AdditionalDependencies) + OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib;AssetPipeline.lib;%(AdditionalDependencies) mkdir "$(TargetDir)ImageConvertTools\" @@ -315,7 +316,8 @@ xcopy /Y /S "$(ProjectDir)..\..\..\..\Tools\ImageConvertTools" "$(TargetDir)Imag xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configuration)\basisu.exe" "$(TargetDir)ImageConvertTools\" - msbuild "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj" /property:Configuration=$(Configuration) /property:Platform=$(Platform) + + @@ -331,11 +333,12 @@ xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configur true + /FS %(AdditionalOptions) Console true - AssetPipeline.lib;%(AdditionalDependencies) + OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib;AssetPipeline.lib;%(AdditionalDependencies) mkdir "$(TargetDir)ImageConvertTools\" @@ -343,7 +346,8 @@ xcopy /Y /S "$(ProjectDir)..\..\..\..\Tools\ImageConvertTools" "$(TargetDir)Imag xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configuration)\basisu.exe" "$(TargetDir)ImageConvertTools\" - msbuild "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj" /property:Configuration=$(Configuration) /property:Platform=$(Platform) + + @@ -359,11 +363,12 @@ xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configur true + /FS %(AdditionalOptions) Console true - AssetPipeline.lib;%(AdditionalDependencies) + OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib;AssetPipeline.lib;%(AdditionalDependencies) mkdir "$(TargetDir)ImageConvertTools\" @@ -371,7 +376,8 @@ xcopy /Y /S "$(ProjectDir)..\..\..\..\Tools\ImageConvertTools" "$(TargetDir)Imag xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configuration)\basisu.exe" "$(TargetDir)ImageConvertTools\" - msbuild "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj" /property:Configuration=$(Configuration) /property:Platform=$(Platform) + + @@ -449,13 +455,14 @@ xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configur true + /FS %(AdditionalOptions) Console true true true - AssetPipeline.lib;%(AdditionalDependencies) + OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib;AssetPipeline.lib;%(AdditionalDependencies) mkdir "$(TargetDir)ImageConvertTools\" @@ -463,7 +470,8 @@ xcopy /Y /S "$(ProjectDir)..\..\..\..\Tools\ImageConvertTools" "$(TargetDir)Imag xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configuration)\basisu.exe" "$(TargetDir)ImageConvertTools\" - msbuild "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj" /property:Configuration=$(Configuration) /property:Platform=$(Platform) + + @@ -481,13 +489,14 @@ xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configur true + /FS %(AdditionalOptions) Console true true true - AssetPipeline.lib;%(AdditionalDependencies) + OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib;AssetPipeline.lib;%(AdditionalDependencies) mkdir "$(TargetDir)ImageConvertTools\" @@ -495,7 +504,8 @@ xcopy /Y /S "$(ProjectDir)..\..\..\..\Tools\ImageConvertTools" "$(TargetDir)Imag xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configuration)\basisu.exe" "$(TargetDir)ImageConvertTools\" - msbuild "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj" /property:Configuration=$(Configuration) /property:Platform=$(Platform) + + @@ -513,13 +523,14 @@ xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configur true + /FS %(AdditionalOptions) Console true true true - AssetPipeline.lib;%(AdditionalDependencies) + OS.lib;MeshOptimizer.lib;ozz_animation.lib;ozz_base.lib;ozz_animation_offline.lib;zlibstatic.lib;IrrXML.lib;assimp.lib;AssetPipeline.lib;%(AdditionalDependencies) mkdir "$(TargetDir)ImageConvertTools\" @@ -527,7 +538,8 @@ xcopy /Y /S "$(ProjectDir)..\..\..\..\Tools\ImageConvertTools" "$(TargetDir)Imag xcopy /Y "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\$(Configuration)\basisu.exe" "$(TargetDir)ImageConvertTools\" - msbuild "$(ProjectDir)..\..\..\ThirdParty\OpenSource\basis_universal\basisu.vcxproj" /property:Configuration=$(Configuration) /property:Platform=$(Platform) + + diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/InverseKinematic.NativeActivity.vcxproj b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/InverseKinematic.NativeActivity.vcxproj new file mode 100644 index 0000000000..b5ecd973b3 --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/InverseKinematic.NativeActivity.vcxproj @@ -0,0 +1,413 @@ + + + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + x64 + + + Release + x64 + + + Debug + x86 + + + Release + x86 + + + + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2} + Android + InverseKinematic + en-US + 14.0 + Android + 3.0 + + + + DynamicLibrary + true + Clang_5_0 + android-29 + c++_shared + ARM + + + DynamicLibrary + false + Clang_5_0 + android-29 + c++_shared + ARM + + + DynamicLibrary + true + Clang_5_0 + android-29 + c++_shared + ARM + + + DynamicLibrary + false + Clang_5_0 + android-29 + c++_shared + ARM + + + DynamicLibrary + true + Clang_5_0 + android-28 + c++_shared + + + DynamicLibrary + false + Clang_5_0 + android-28 + c++_shared + + + DynamicLibrary + true + Clang_5_0 + android-28 + c++_shared + ARM + + + DynamicLibrary + false + Clang_5_0 + android-28 + c++_shared + ARM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VS_NdkRoot)\toolchains\llvm\prebuilt\windows-x86_64\bin + $(CustomSysroot)\usr\include;$(CustomSysroot)\usr\include\$(TRIPLE);$(VS_Ndkroot)\sources\android\native_app_glue + true + + + + NotUsing + pch.h + CompileAsCpp + Disabled + c++11 + _DEBUG;VULKAN;ANDROID;VK_USE_PLATFORM_ANDROID_KHR;ANDROID_ARM_NEON + softfp + -Wno-c++14-extensions %(AdditionalOptions) + + + $(VS_Ndkroot)\sources\third_party\shaderc\libs\$(UseOfStl)\$(TargetArchAbi);$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) + -lm -lc++_shared -lc++abi -llog -landroid %(AdditionalOptions) + Renderer;SpirvTools;OS;gainputstatic;ozz_animation;ozz_base;shaderc + + + $(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Disabled + softfp + c++11 + VULKAN;ANDROID;VK_USE_PLATFORM_ANDROID_KHR;ANDROID_ARM_NEON + -Wno-c++14-extensions %(AdditionalOptions) + + + $(VS_Ndkroot)\sources\third_party\shaderc\libs\$(UseOfStl)\$(TargetArchAbi);$(SolutionDir)$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories) + -lm -lc++_shared -lc++abi -llog -landroid %(AdditionalOptions) + Renderer;SpirvTools;OS;gainputstatic;ozz_animation;ozz_base;shaderc + + + $(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Disabled + softfp + c++11 + VULKAN;ANDROID;VK_USE_PLATFORM_ANDROID_KHR;ANDROID_ARM_NEON;_DEBUG + -std=c++14 -mfloat-abi=softfp -mfpu=neon -Wno-c++14-extensions %(AdditionalOptions) + true + + + Renderer;SpirvTools;OS;gainputstatic;ozz_animation;ozz_base;shaderc;%(LibraryDependencies) + $(SolutionDir)$(Platform)\$(Configuration)\;$(VS_Ndkroot)\sources\third_party\shaderc\libs\$(UseOfStl)\$(TargetArchAbi);%(AdditionalLibraryDirectories) + -lm %(AdditionalOptions) + + + $(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Disabled + softfp + c++11 + ANDROID;VULKAN;%(PreprocessorDefinitions) + -Wno-c++14-extensions %(AdditionalOptions) + true + + + %(LibraryDependencies);Renderer;SpirvTools;OS;gainputstatic;ozz_animation;ozz_base;shaderc + $(SolutionDir)$(Platform)\$(Configuration)\;$(VS_Ndkroot)\sources\third_party\shaderc\libs\$(UseOfStl)\$(TargetArchAbi);%(AdditionalLibraryDirectories) + -lm -lc++_shared -lc++abi -llog -landroid %(AdditionalOptions) + + + $(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\$(RootNameSpace)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Enabled + true + softfp + c++11 + _DEBUG;ANDROID;VULKAN;%(PreprocessorDefinitions) + + + %(LibraryDependencies);GLESv1_CM;EGL; + + + $(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Enabled + true + softfp + c++11 + ANDROID;VULKAN;%(PreprocessorDefinitions) + + + %(LibraryDependencies);GLESv1_CM;EGL; + + + rd /s /q assets +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Enabled + true + softfp + c++11 + _DEBUG;ANDROID;VULKAN;%(PreprocessorDefinitions) + + + %(LibraryDependencies);GLESv1_CM;EGL; + + + $(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y + + + + + + + + + NotUsing + pch.h + CompileAsCpp + Enabled + true + softfp + c++11 + ANDROID;VULKAN;%(PreprocessorDefinitions) + + + %(LibraryDependencies);GLESv1_CM;EGL; + + + rd /s /q assets +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\UnitTestResources\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\UI\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\..\..\Middleware_3\Text\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y +$(systemroot)\System32\xcopy $(ProjectDir)..\..\..\src\26_InverseKinematic\Shaders\Vulkan\*.* $(SolutionDir)$(Platform)\$(Configuration)\assets\Shaders\ /s /y + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/InverseKinematic.NativeActivity.vcxproj.filters b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/InverseKinematic.NativeActivity.vcxproj.filters new file mode 100644 index 0000000000..e4e0f4326a --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/InverseKinematic.NativeActivity.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + + + + + + + + {c9d35bd2-31a7-4923-85f7-ff9bf1a98b75} + + + + + Shaders + + + Shaders + + + Shaders + + + Shaders + + + Shaders + + + Shaders + + + \ No newline at end of file diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/android_native_app_glue.c b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/android_native_app_glue.c similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/android_native_app_glue.c rename to Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/android_native_app_glue.c diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/android_native_app_glue.h b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/android_native_app_glue.h similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/android_native_app_glue.h rename to Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/android_native_app_glue.h diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/main.cpp b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/main.cpp new file mode 100644 index 0000000000..f173de806f --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.NativeActivity/main.cpp @@ -0,0 +1,293 @@ +/* +* Copyright (C) 2010 The Android Open Source Project +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +*/ + +#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "AndroidProject1.NativeActivity", __VA_ARGS__)) +#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "AndroidProject1.NativeActivity", __VA_ARGS__)) + +/** +* Our saved state data. +*/ +struct saved_state { + float angle; + int32_t x; + int32_t y; +}; + +/** +* Shared state for our app. +*/ +struct engine { + struct android_app* app; + + ASensorManager* sensorManager; + const ASensor* accelerometerSensor; + ASensorEventQueue* sensorEventQueue; + + int animating; + EGLDisplay display; + EGLSurface surface; + EGLContext context; + int32_t width; + int32_t height; + struct saved_state state; +}; + +/** +* Initialize an EGL context for the current display. +*/ +static int engine_init_display(struct engine* engine) { + // initialize OpenGL ES and EGL + + /* + * Here specify the attributes of the desired configuration. + * Below, we select an EGLConfig with at least 8 bits per color + * component compatible with on-screen windows + */ + const EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BLUE_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_RED_SIZE, 8, + EGL_NONE + }; + EGLint w, h, format; + EGLint numConfigs; + EGLConfig config; + EGLSurface surface; + EGLContext context; + + EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + + eglInitialize(display, 0, 0); + + /* Here, the application chooses the configuration it desires. In this + * sample, we have a very simplified selection process, where we pick + * the first EGLConfig that matches our criteria */ + eglChooseConfig(display, attribs, &config, 1, &numConfigs); + + /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is + * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). + * As soon as we picked a EGLConfig, we can safely reconfigure the + * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */ + eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); + + ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format); + + surface = eglCreateWindowSurface(display, config, engine->app->window, NULL); + context = eglCreateContext(display, config, NULL, NULL); + + if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { + LOGW("Unable to eglMakeCurrent"); + return -1; + } + + eglQuerySurface(display, surface, EGL_WIDTH, &w); + eglQuerySurface(display, surface, EGL_HEIGHT, &h); + + engine->display = display; + engine->context = context; + engine->surface = surface; + engine->width = w; + engine->height = h; + engine->state.angle = 0; + + // Initialize GL state. + glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); + glEnable(GL_CULL_FACE); + glShadeModel(GL_SMOOTH); + glDisable(GL_DEPTH_TEST); + + return 0; +} + +/** +* Just the current frame in the display. +*/ +static void engine_draw_frame(struct engine* engine) { + if (engine->display == NULL) { + // No display. + return; + } + + // Just fill the screen with a color. + glClearColor(((float)engine->state.x) / engine->width, engine->state.angle, + ((float)engine->state.y) / engine->height, 1); + glClear(GL_COLOR_BUFFER_BIT); + + eglSwapBuffers(engine->display, engine->surface); +} + +/** +* Tear down the EGL context currently associated with the display. +*/ +static void engine_term_display(struct engine* engine) { + if (engine->display != EGL_NO_DISPLAY) { + eglMakeCurrent(engine->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + if (engine->context != EGL_NO_CONTEXT) { + eglDestroyContext(engine->display, engine->context); + } + if (engine->surface != EGL_NO_SURFACE) { + eglDestroySurface(engine->display, engine->surface); + } + eglTerminate(engine->display); + } + engine->animating = 0; + engine->display = EGL_NO_DISPLAY; + engine->context = EGL_NO_CONTEXT; + engine->surface = EGL_NO_SURFACE; +} + +/** +* Process the next input event. +*/ +static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) { + struct engine* engine = (struct engine*)app->userData; + if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) { + engine->state.x = AMotionEvent_getX(event, 0); + engine->state.y = AMotionEvent_getY(event, 0); + return 1; + } + return 0; +} + +/** +* Process the next main command. +*/ +static void engine_handle_cmd(struct android_app* app, int32_t cmd) { + struct engine* engine = (struct engine*)app->userData; + switch (cmd) { + case APP_CMD_SAVE_STATE: + // The system has asked us to save our current state. Do so. + engine->app->savedState = malloc(sizeof(struct saved_state)); + *((struct saved_state*)engine->app->savedState) = engine->state; + engine->app->savedStateSize = sizeof(struct saved_state); + break; + case APP_CMD_INIT_WINDOW: + // The window is being shown, get it ready. + if (engine->app->window != NULL) { + engine_init_display(engine); + engine_draw_frame(engine); + } + break; + case APP_CMD_TERM_WINDOW: + // The window is being hidden or closed, clean it up. + engine_term_display(engine); + break; + case APP_CMD_GAINED_FOCUS: + // When our app gains focus, we start monitoring the accelerometer. + if (engine->accelerometerSensor != NULL) { + ASensorEventQueue_enableSensor(engine->sensorEventQueue, + engine->accelerometerSensor); + // We'd like to get 60 events per second (in us). + ASensorEventQueue_setEventRate(engine->sensorEventQueue, + engine->accelerometerSensor, (1000L / 60) * 1000); + } + break; + case APP_CMD_LOST_FOCUS: + // When our app loses focus, we stop monitoring the accelerometer. + // This is to avoid consuming battery while not being used. + if (engine->accelerometerSensor != NULL) { + ASensorEventQueue_disableSensor(engine->sensorEventQueue, + engine->accelerometerSensor); + } + // Also stop animating. + engine->animating = 0; + engine_draw_frame(engine); + break; + } +} + +/** +* This is the main entry point of a native application that is using +* android_native_app_glue. It runs in its own thread, with its own +* event loop for receiving input events and doing other things. +*/ +void android_main(struct android_app* state) { + struct engine engine; + + memset(&engine, 0, sizeof(engine)); + state->userData = &engine; + state->onAppCmd = engine_handle_cmd; + state->onInputEvent = engine_handle_input; + engine.app = state; + + // Prepare to monitor accelerometer + engine.sensorManager = ASensorManager_getInstance(); + engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, + ASENSOR_TYPE_ACCELEROMETER); + engine.sensorEventQueue = ASensorManager_createEventQueue(engine.sensorManager, + state->looper, LOOPER_ID_USER, NULL, NULL); + + if (state->savedState != NULL) { + // We are starting with a previous saved state; restore from it. + engine.state = *(struct saved_state*)state->savedState; + } + + engine.animating = 1; + + // loop waiting for stuff to do. + + while (1) { + // Read all pending events. + int ident; + int events; + struct android_poll_source* source; + + // If not animating, we will block forever waiting for events. + // If animating, we loop until all events are read, then continue + // to draw the next frame of animation. + while ((ident = ALooper_pollAll(engine.animating ? 0 : -1, NULL, &events, + (void**)&source)) >= 0) { + + // Process this event. + if (source != NULL) { + source->process(state, source); + } + + // If a sensor has data, process it now. + if (ident == LOOPER_ID_USER) { + if (engine.accelerometerSensor != NULL) { + ASensorEvent event; + while (ASensorEventQueue_getEvents(engine.sensorEventQueue, + &event, 1) > 0) { + LOGI("accelerometer: x=%f y=%f z=%f", + event.acceleration.x, event.acceleration.y, + event.acceleration.z); + } + } + } + + // Check if we are exiting. + if (state->destroyRequested != 0) { + engine_term_display(&engine); + return; + } + } + + if (engine.animating) { + // Done with events; draw next animation frame. + engine.state.angle += .01f; + if (engine.state.angle > 1) { + engine.state.angle = 0; + } + + // Drawing is throttled to the screen update rate, so there + // is no need to do timing here. + engine_draw_frame(&engine); + } + } +} diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/AndroidManifest.xml b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/AndroidManifest.xml new file mode 100644 index 0000000000..da180f7e6a --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/AndroidManifest.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/InverseKinematic.Packaging.androidproj b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/InverseKinematic.Packaging.androidproj new file mode 100644 index 0000000000..81065bc60d --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/InverseKinematic.Packaging.androidproj @@ -0,0 +1,181 @@ + + + + + Debug + ARM + + + Release + ARM + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + x64 + + + Release + x64 + + + Debug + x86 + + + Release + x86 + + + + InverseKinematic + 14.0 + 1.0 + e0a67149-16f7-4531-b5fe-d14f8cb7742c + + + + true + Application + android-25 + + + false + Application + android-25 + + + true + Application + android-25 + + + false + Application + android-25 + + + true + Application + android-25 + + + false + Application + android-25 + + + true + Application + android-25 + + + false + Application + android-25 + + + + + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + $(RootNamespace) + $(SolutionDir)$(Platform)\$(Configuration)\$(RootNamespace) + + + + + + + + + + + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2} + + + + + \ No newline at end of file diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/build.xml b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/build.xml similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/build.xml rename to Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/build.xml diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/project.properties b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/project.properties similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/project.properties rename to Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/project.properties diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/res/values/strings.xml b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/res/values/strings.xml new file mode 100644 index 0000000000..80e1dad5d4 --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/26_InverseKinematic/InverseKinematic.Packaging/res/values/strings.xml @@ -0,0 +1,4 @@ + + + InverseKinematic + diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj similarity index 99% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj rename to Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj index a196e82ef5..294552139f 100644 --- a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj @@ -346,7 +346,7 @@ - + diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj.filters b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj.filters similarity index 82% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj.filters rename to Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj.filters index a293fb4536..6ab94da189 100644 --- a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj.filters +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/Audio.NativeActivity.vcxproj.filters @@ -5,6 +5,6 @@ - + \ No newline at end of file diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/android_native_app_glue.c b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/android_native_app_glue.c new file mode 100644 index 0000000000..84f6c82783 --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/android_native_app_glue.c @@ -0,0 +1,442 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include +#include "android_native_app_glue.h" +#include + +#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__)) +#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "threaded_app", __VA_ARGS__)) + +/* For debug builds, always enable the debug traces in this library */ +#ifndef NDEBUG +# define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "threaded_app", __VA_ARGS__)) +#else +# define LOGV(...) ((void)0) +#endif + +static void free_saved_state(struct android_app* android_app) { + pthread_mutex_lock(&android_app->mutex); + if (android_app->savedState != NULL) { + free(android_app->savedState); + android_app->savedState = NULL; + android_app->savedStateSize = 0; + } + pthread_mutex_unlock(&android_app->mutex); +} + +int8_t android_app_read_cmd(struct android_app* android_app) { + int8_t cmd; + if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) { + switch (cmd) { + case APP_CMD_SAVE_STATE: + free_saved_state(android_app); + break; + } + return cmd; + } else { + LOGE("No data on command pipe!"); + } + return -1; +} + +static void print_cur_config(struct android_app* android_app) { + char lang[2], country[2]; + AConfiguration_getLanguage(android_app->config, lang); + AConfiguration_getCountry(android_app->config, country); + + LOGV("Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d " + "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d " + "modetype=%d modenight=%d", + AConfiguration_getMcc(android_app->config), + AConfiguration_getMnc(android_app->config), + lang[0], lang[1], country[0], country[1], + AConfiguration_getOrientation(android_app->config), + AConfiguration_getTouchscreen(android_app->config), + AConfiguration_getDensity(android_app->config), + AConfiguration_getKeyboard(android_app->config), + AConfiguration_getNavigation(android_app->config), + AConfiguration_getKeysHidden(android_app->config), + AConfiguration_getNavHidden(android_app->config), + AConfiguration_getSdkVersion(android_app->config), + AConfiguration_getScreenSize(android_app->config), + AConfiguration_getScreenLong(android_app->config), + AConfiguration_getUiModeType(android_app->config), + AConfiguration_getUiModeNight(android_app->config)); +} + +void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) { + switch (cmd) { + case APP_CMD_INPUT_CHANGED: + LOGV("APP_CMD_INPUT_CHANGED\n"); + pthread_mutex_lock(&android_app->mutex); + if (android_app->inputQueue != NULL) { + AInputQueue_detachLooper(android_app->inputQueue); + } + android_app->inputQueue = android_app->pendingInputQueue; + if (android_app->inputQueue != NULL) { + LOGV("Attaching input queue to looper"); + AInputQueue_attachLooper(android_app->inputQueue, + android_app->looper, LOOPER_ID_INPUT, NULL, + &android_app->inputPollSource); + } + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_INIT_WINDOW: + LOGV("APP_CMD_INIT_WINDOW\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->window = android_app->pendingWindow; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_TERM_WINDOW: + LOGV("APP_CMD_TERM_WINDOW\n"); + pthread_cond_broadcast(&android_app->cond); + break; + + case APP_CMD_RESUME: + case APP_CMD_START: + case APP_CMD_PAUSE: + case APP_CMD_STOP: + LOGV("activityState=%d\n", cmd); + pthread_mutex_lock(&android_app->mutex); + android_app->activityState = cmd; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_CONFIG_CHANGED: + LOGV("APP_CMD_CONFIG_CHANGED\n"); + AConfiguration_fromAssetManager(android_app->config, + android_app->activity->assetManager); + print_cur_config(android_app); + break; + + case APP_CMD_DESTROY: + LOGV("APP_CMD_DESTROY\n"); + android_app->destroyRequested = 1; + break; + } +} + +void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) { + switch (cmd) { + case APP_CMD_TERM_WINDOW: + LOGV("APP_CMD_TERM_WINDOW\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->window = NULL; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_SAVE_STATE: + LOGV("APP_CMD_SAVE_STATE\n"); + pthread_mutex_lock(&android_app->mutex); + android_app->stateSaved = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + break; + + case APP_CMD_RESUME: + free_saved_state(android_app); + break; + } +} + +static void android_app_destroy(struct android_app* android_app) { + LOGV("android_app_destroy!"); + free_saved_state(android_app); + pthread_mutex_lock(&android_app->mutex); + if (android_app->inputQueue != NULL) { + AInputQueue_detachLooper(android_app->inputQueue); + } + AConfiguration_delete(android_app->config); + android_app->destroyed = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + // Can't touch android_app object after this. +} + +static void process_input(struct android_app* app, struct android_poll_source* source) { + AInputEvent* event = NULL; + while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { + LOGV("New input event: type=%d\n", AInputEvent_getType(event)); + if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { + continue; + } + int32_t handled = 0; + if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); + AInputQueue_finishEvent(app->inputQueue, event, handled); + } +} + +static void process_cmd(struct android_app* app, struct android_poll_source* source) { + int8_t cmd = android_app_read_cmd(app); + android_app_pre_exec_cmd(app, cmd); + if (app->onAppCmd != NULL) app->onAppCmd(app, cmd); + android_app_post_exec_cmd(app, cmd); +} + +static void* android_app_entry(void* param) { + struct android_app* android_app = (struct android_app*)param; + + android_app->config = AConfiguration_new(); + AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager); + + print_cur_config(android_app); + + android_app->cmdPollSource.id = LOOPER_ID_MAIN; + android_app->cmdPollSource.app = android_app; + android_app->cmdPollSource.process = process_cmd; + android_app->inputPollSource.id = LOOPER_ID_INPUT; + android_app->inputPollSource.app = android_app; + android_app->inputPollSource.process = process_input; + + ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); + ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL, + &android_app->cmdPollSource); + android_app->looper = looper; + + pthread_mutex_lock(&android_app->mutex); + android_app->running = 1; + pthread_cond_broadcast(&android_app->cond); + pthread_mutex_unlock(&android_app->mutex); + + android_main(android_app); + + android_app_destroy(android_app); + return NULL; +} + +// -------------------------------------------------------------------- +// Native activity interaction (called from main thread) +// -------------------------------------------------------------------- + +static struct android_app* android_app_create(ANativeActivity* activity, + void* savedState, size_t savedStateSize) { + struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app)); + memset(android_app, 0, sizeof(struct android_app)); + android_app->activity = activity; + + pthread_mutex_init(&android_app->mutex, NULL); + pthread_cond_init(&android_app->cond, NULL); + + if (savedState != NULL) { + android_app->savedState = malloc(savedStateSize); + android_app->savedStateSize = savedStateSize; + memcpy(android_app->savedState, savedState, savedStateSize); + } + + int msgpipe[2]; + if (pipe(msgpipe)) { + LOGE("could not create pipe: %s", strerror(errno)); + return NULL; + } + android_app->msgread = msgpipe[0]; + android_app->msgwrite = msgpipe[1]; + + pthread_attr_t attr; + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); + pthread_create(&android_app->thread, &attr, android_app_entry, android_app); + + // Wait for thread to start. + pthread_mutex_lock(&android_app->mutex); + while (!android_app->running) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); + + return android_app; +} + +static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) { + if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) { + LOGE("Failure writing android_app cmd: %s\n", strerror(errno)); + } +} + +static void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) { + pthread_mutex_lock(&android_app->mutex); + android_app->pendingInputQueue = inputQueue; + android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED); + while (android_app->inputQueue != android_app->pendingInputQueue) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_set_window(struct android_app* android_app, ANativeWindow* window) { + pthread_mutex_lock(&android_app->mutex); + if (android_app->pendingWindow != NULL) { + android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW); + } + android_app->pendingWindow = window; + if (window != NULL) { + android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW); + } + while (android_app->window != android_app->pendingWindow) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) { + pthread_mutex_lock(&android_app->mutex); + android_app_write_cmd(android_app, cmd); + while (android_app->activityState != cmd) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); +} + +static void android_app_free(struct android_app* android_app) { + pthread_mutex_lock(&android_app->mutex); + android_app_write_cmd(android_app, APP_CMD_DESTROY); + while (!android_app->destroyed) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + pthread_mutex_unlock(&android_app->mutex); + + close(android_app->msgread); + close(android_app->msgwrite); + pthread_cond_destroy(&android_app->cond); + pthread_mutex_destroy(&android_app->mutex); + free(android_app); +} + +static void onDestroy(ANativeActivity* activity) { + LOGV("Destroy: %p\n", activity); + android_app_free((struct android_app*)activity->instance); +} + +static void onStart(ANativeActivity* activity) { + LOGV("Start: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_START); +} + +static void onResume(ANativeActivity* activity) { + LOGV("Resume: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_RESUME); +} + +static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) { + struct android_app* android_app = (struct android_app*)activity->instance; + void* savedState = NULL; + + LOGV("SaveInstanceState: %p\n", activity); + pthread_mutex_lock(&android_app->mutex); + android_app->stateSaved = 0; + android_app_write_cmd(android_app, APP_CMD_SAVE_STATE); + while (!android_app->stateSaved) { + pthread_cond_wait(&android_app->cond, &android_app->mutex); + } + + if (android_app->savedState != NULL) { + savedState = android_app->savedState; + *outLen = android_app->savedStateSize; + android_app->savedState = NULL; + android_app->savedStateSize = 0; + } + + pthread_mutex_unlock(&android_app->mutex); + + return savedState; +} + +static void onPause(ANativeActivity* activity) { + LOGV("Pause: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_PAUSE); +} + +static void onStop(ANativeActivity* activity) { + LOGV("Stop: %p\n", activity); + android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP); +} + +static void onConfigurationChanged(ANativeActivity* activity) { + struct android_app* android_app = (struct android_app*)activity->instance; + LOGV("ConfigurationChanged: %p\n", activity); + android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED); +} + +static void onLowMemory(ANativeActivity* activity) { + struct android_app* android_app = (struct android_app*)activity->instance; + LOGV("LowMemory: %p\n", activity); + android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY); +} + +static void onWindowFocusChanged(ANativeActivity* activity, int focused) { + LOGV("WindowFocusChanged: %p -- %d\n", activity, focused); + android_app_write_cmd((struct android_app*)activity->instance, + focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS); +} + +static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window) { + LOGV("NativeWindowCreated: %p -- %p\n", activity, window); + android_app_set_window((struct android_app*)activity->instance, window); +} + +static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) { + LOGV("NativeWindowDestroyed: %p -- %p\n", activity, window); + android_app_set_window((struct android_app*)activity->instance, NULL); +} + +static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) { + LOGV("InputQueueCreated: %p -- %p\n", activity, queue); + android_app_set_input((struct android_app*)activity->instance, queue); +} + +static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) { + LOGV("InputQueueDestroyed: %p -- %p\n", activity, queue); + android_app_set_input((struct android_app*)activity->instance, NULL); +} + +void ANativeActivity_onCreate(ANativeActivity* activity, + void* savedState, size_t savedStateSize) { + LOGV("Creating: %p\n", activity); + activity->callbacks->onDestroy = onDestroy; + activity->callbacks->onStart = onStart; + activity->callbacks->onResume = onResume; + activity->callbacks->onSaveInstanceState = onSaveInstanceState; + activity->callbacks->onPause = onPause; + activity->callbacks->onStop = onStop; + activity->callbacks->onConfigurationChanged = onConfigurationChanged; + activity->callbacks->onLowMemory = onLowMemory; + activity->callbacks->onWindowFocusChanged = onWindowFocusChanged; + activity->callbacks->onNativeWindowCreated = onNativeWindowCreated; + activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed; + activity->callbacks->onInputQueueCreated = onInputQueueCreated; + activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed; + + activity->instance = android_app_create(activity, savedState, savedStateSize); +} diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/android_native_app_glue.h b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/android_native_app_glue.h new file mode 100644 index 0000000000..1b390c2d46 --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.NativeActivity/android_native_app_glue.h @@ -0,0 +1,344 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _ANDROID_NATIVE_APP_GLUE_H +#define _ANDROID_NATIVE_APP_GLUE_H + +#include +#include +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * The native activity interface provided by + * is based on a set of application-provided callbacks that will be called + * by the Activity's main thread when certain events occur. + * + * This means that each one of this callbacks _should_ _not_ block, or they + * risk having the system force-close the application. This programming + * model is direct, lightweight, but constraining. + * + * The 'threaded_native_app' static library is used to provide a different + * execution model where the application can implement its own main event + * loop in a different thread instead. Here's how it works: + * + * 1/ The application must provide a function named "android_main()" that + * will be called when the activity is created, in a new thread that is + * distinct from the activity's main thread. + * + * 2/ android_main() receives a pointer to a valid "android_app" structure + * that contains references to other important objects, e.g. the + * ANativeActivity obejct instance the application is running in. + * + * 3/ the "android_app" object holds an ALooper instance that already + * listens to two important things: + * + * - activity lifecycle events (e.g. "pause", "resume"). See APP_CMD_XXX + * declarations below. + * + * - input events coming from the AInputQueue attached to the activity. + * + * Each of these correspond to an ALooper identifier returned by + * ALooper_pollOnce with values of LOOPER_ID_MAIN and LOOPER_ID_INPUT, + * respectively. + * + * Your application can use the same ALooper to listen to additional + * file-descriptors. They can either be callback based, or with return + * identifiers starting with LOOPER_ID_USER. + * + * 4/ Whenever you receive a LOOPER_ID_MAIN or LOOPER_ID_INPUT event, + * the returned data will point to an android_poll_source structure. You + * can call the process() function on it, and fill in android_app->onAppCmd + * and android_app->onInputEvent to be called for your own processing + * of the event. + * + * Alternatively, you can call the low-level functions to read and process + * the data directly... look at the process_cmd() and process_input() + * implementations in the glue to see how to do this. + * + * See the sample named "native-activity" that comes with the NDK with a + * full usage example. Also look at the JavaDoc of NativeActivity. + */ + +struct android_app; + +/** + * Data associated with an ALooper fd that will be returned as the "outData" + * when that source has data ready. + */ +struct android_poll_source { + // The identifier of this source. May be LOOPER_ID_MAIN or + // LOOPER_ID_INPUT. + int32_t id; + + // The android_app this ident is associated with. + struct android_app* app; + + // Function to call to perform the standard processing of data from + // this source. + void (*process)(struct android_app* app, struct android_poll_source* source); +}; + +/** + * This is the interface for the standard glue code of a threaded + * application. In this model, the application's code is running + * in its own thread separate from the main thread of the process. + * It is not required that this thread be associated with the Java + * VM, although it will need to be in order to make JNI calls any + * Java objects. + */ +struct android_app { + // The application can place a pointer to its own state object + // here if it likes. + void* userData; + + // Fill this in with the function to process main app commands (APP_CMD_*) + void (*onAppCmd)(struct android_app* app, int32_t cmd); + + // Fill this in with the function to process input events. At this point + // the event has already been pre-dispatched, and it will be finished upon + // return. Return 1 if you have handled the event, 0 for any default + // dispatching. + int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event); + + // The ANativeActivity object instance that this app is running in. + ANativeActivity* activity; + + // The current configuration the app is running in. + AConfiguration* config; + + // This is the last instance's saved state, as provided at creation time. + // It is NULL if there was no state. You can use this as you need; the + // memory will remain around until you call android_app_exec_cmd() for + // APP_CMD_RESUME, at which point it will be freed and savedState set to NULL. + // These variables should only be changed when processing a APP_CMD_SAVE_STATE, + // at which point they will be initialized to NULL and you can malloc your + // state and place the information here. In that case the memory will be + // freed for you later. + void* savedState; + size_t savedStateSize; + + // The ALooper associated with the app's thread. + ALooper* looper; + + // When non-NULL, this is the input queue from which the app will + // receive user input events. + AInputQueue* inputQueue; + + // When non-NULL, this is the window surface that the app can draw in. + ANativeWindow* window; + + // Current content rectangle of the window; this is the area where the + // window's content should be placed to be seen by the user. + ARect contentRect; + + // Current state of the app's activity. May be either APP_CMD_START, + // APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below. + int activityState; + + // This is non-zero when the application's NativeActivity is being + // destroyed and waiting for the app thread to complete. + int destroyRequested; + + // ------------------------------------------------- + // Below are "private" implementation of the glue code. + + pthread_mutex_t mutex; + pthread_cond_t cond; + + int msgread; + int msgwrite; + + pthread_t thread; + + struct android_poll_source cmdPollSource; + struct android_poll_source inputPollSource; + + int running; + int stateSaved; + int destroyed; + int redrawNeeded; + AInputQueue* pendingInputQueue; + ANativeWindow* pendingWindow; + ARect pendingContentRect; +}; + +enum { + /** + * Looper data ID of commands coming from the app's main thread, which + * is returned as an identifier from ALooper_pollOnce(). The data for this + * identifier is a pointer to an android_poll_source structure. + * These can be retrieved and processed with android_app_read_cmd() + * and android_app_exec_cmd(). + */ + LOOPER_ID_MAIN = 1, + + /** + * Looper data ID of events coming from the AInputQueue of the + * application's window, which is returned as an identifier from + * ALooper_pollOnce(). The data for this identifier is a pointer to an + * android_poll_source structure. These can be read via the inputQueue + * object of android_app. + */ + LOOPER_ID_INPUT = 2, + + /** + * Start of user-defined ALooper identifiers. + */ + LOOPER_ID_USER = 3, +}; + +enum { + /** + * Command from main thread: the AInputQueue has changed. Upon processing + * this command, android_app->inputQueue will be updated to the new queue + * (or NULL). + */ + APP_CMD_INPUT_CHANGED, + + /** + * Command from main thread: a new ANativeWindow is ready for use. Upon + * receiving this command, android_app->window will contain the new window + * surface. + */ + APP_CMD_INIT_WINDOW, + + /** + * Command from main thread: the existing ANativeWindow needs to be + * terminated. Upon receiving this command, android_app->window still + * contains the existing window; after calling android_app_exec_cmd + * it will be set to NULL. + */ + APP_CMD_TERM_WINDOW, + + /** + * Command from main thread: the current ANativeWindow has been resized. + * Please redraw with its new size. + */ + APP_CMD_WINDOW_RESIZED, + + /** + * Command from main thread: the system needs that the current ANativeWindow + * be redrawn. You should redraw the window before handing this to + * android_app_exec_cmd() in order to avoid transient drawing glitches. + */ + APP_CMD_WINDOW_REDRAW_NEEDED, + + /** + * Command from main thread: the content area of the window has changed, + * such as from the soft input window being shown or hidden. You can + * find the new content rect in android_app::contentRect. + */ + APP_CMD_CONTENT_RECT_CHANGED, + + /** + * Command from main thread: the app's activity window has gained + * input focus. + */ + APP_CMD_GAINED_FOCUS, + + /** + * Command from main thread: the app's activity window has lost + * input focus. + */ + APP_CMD_LOST_FOCUS, + + /** + * Command from main thread: the current device configuration has changed. + */ + APP_CMD_CONFIG_CHANGED, + + /** + * Command from main thread: the system is running low on memory. + * Try to reduce your memory use. + */ + APP_CMD_LOW_MEMORY, + + /** + * Command from main thread: the app's activity has been started. + */ + APP_CMD_START, + + /** + * Command from main thread: the app's activity has been resumed. + */ + APP_CMD_RESUME, + + /** + * Command from main thread: the app should generate a new saved state + * for itself, to restore from later if needed. If you have saved state, + * allocate it with malloc and place it in android_app.savedState with + * the size in android_app.savedStateSize. The will be freed for you + * later. + */ + APP_CMD_SAVE_STATE, + + /** + * Command from main thread: the app's activity has been paused. + */ + APP_CMD_PAUSE, + + /** + * Command from main thread: the app's activity has been stopped. + */ + APP_CMD_STOP, + + /** + * Command from main thread: the app's activity is being destroyed, + * and waiting for the app thread to clean up and exit before proceeding. + */ + APP_CMD_DESTROY, +}; + +/** + * Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next + * app command message. + */ +int8_t android_app_read_cmd(struct android_app* android_app); + +/** + * Call with the command returned by android_app_read_cmd() to do the + * initial pre-processing of the given command. You can perform your own + * actions for the command after calling this function. + */ +void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd); + +/** + * Call with the command returned by android_app_read_cmd() to do the + * final post-processing of the given command. You must have done your own + * actions for the command before calling this function. + */ +void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd); + +/** + * This is the function that application code must implement, representing + * the main entry to the app. + */ +extern void android_main(struct android_app* app); + +#ifdef __cplusplus +} +#endif + +#endif /* _ANDROID_NATIVE_APP_GLUE_H */ diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/AndroidManifest.xml b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/AndroidManifest.xml similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/AndroidManifest.xml rename to Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/AndroidManifest.xml diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/Audio.Packaging.androidproj b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/Audio.Packaging.androidproj similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/Audio.Packaging.androidproj rename to Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/Audio.Packaging.androidproj diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/build.xml b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/build.xml new file mode 100644 index 0000000000..0abadec58e --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/build.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/project.properties b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/project.properties new file mode 100644 index 0000000000..802a49f6b2 --- /dev/null +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/project.properties @@ -0,0 +1,3 @@ +# Project target +target=$(androidapilevel) +# Provide path to the directory where prebuilt external jar files are by setting jar.libs.dir= diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/res/values/strings.xml b/Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/res/values/strings.xml similarity index 100% rename from Examples_3/Unit_Tests/Android_VisualStudio2017/26_Audio/Audio.Packaging/res/values/strings.xml rename to Examples_3/Unit_Tests/Android_VisualStudio2017/27_Audio/Audio.Packaging/res/values/strings.xml diff --git a/Examples_3/Unit_Tests/Android_VisualStudio2017/Unit_Tests.sln b/Examples_3/Unit_Tests/Android_VisualStudio2017/Unit_Tests.sln index a1f4caa665..d79423725a 100644 --- a/Examples_3/Unit_Tests/Android_VisualStudio2017/Unit_Tests.sln +++ b/Examples_3/Unit_Tests/Android_VisualStudio2017/Unit_Tests.sln @@ -179,14 +179,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaterialPlayground.NativeAc EndProject Project("{39E2626F-3545-4960-A6E8-258AD8476CE5}") = "MaterialPlayground.Packaging", "06_MaterialPlayground\MaterialPlayground.Packaging\MaterialPlayground.Packaging.androidproj", "{029CAD36-3A3D-4AD9-A7C7-C283742F44EE}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "26_Audio", "26_Audio", "{9299DEAB-C667-4235-AD22-084C21A3098D}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "27_Audio", "27_Audio", "{9299DEAB-C667-4235-AD22-084C21A3098D}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Audio.NativeActivity", "26_Audio\Audio.NativeActivity\Audio.NativeActivity.vcxproj", "{FD5F23FF-C6B6-4465-900B-E4CC499B7F38}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Audio.NativeActivity", "27_Audio\Audio.NativeActivity\Audio.NativeActivity.vcxproj", "{FD5F23FF-C6B6-4465-900B-E4CC499B7F38}" ProjectSection(ProjectDependencies) = postProject {29FAB285-1EF0-4F63-9F85-D78DA2E88462} = {29FAB285-1EF0-4F63-9F85-D78DA2E88462} EndProjectSection EndProject -Project("{39E2626F-3545-4960-A6E8-258AD8476CE5}") = "Audio.Packaging", "26_Audio\Audio.Packaging\Audio.Packaging.androidproj", "{3CB940C5-9C3E-427A-B165-B43924B57E04}" +Project("{39E2626F-3545-4960-A6E8-258AD8476CE5}") = "Audio.Packaging", "27_Audio\Audio.Packaging\Audio.Packaging.androidproj", "{3CB940C5-9C3E-427A-B165-B43924B57E04}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BuildAll", "AllLibrariesBuild\BuildAll.vcxproj", "{29FAB285-1EF0-4F63-9F85-D78DA2E88462}" ProjectSection(ProjectDependencies) = postProject @@ -217,6 +217,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetPipeline", "Libraries\ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MeshOptimizer", "Libraries\Tools\MeshOptimizer\MeshOptimizer.vcxproj", "{91917FF4-AAE0-4487-B1D1-2D09F723CEC9}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "26_InverseKinematic", "26_InverseKinematic", "{35AB2208-85FF-4E42-A583-8281E7756712}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InverseKinematic.NativeActivity", "26_InverseKinematic\InverseKinematic.NativeActivity\InverseKinematic.NativeActivity.vcxproj", "{6A5D203F-5617-4CD2-BFC3-17B01740BBF2}" + ProjectSection(ProjectDependencies) = postProject + {29FAB285-1EF0-4F63-9F85-D78DA2E88462} = {29FAB285-1EF0-4F63-9F85-D78DA2E88462} + {A4C073AB-608B-4E1C-B24A-9E3919235F0C} = {A4C073AB-608B-4E1C-B24A-9E3919235F0C} + EndProjectSection +EndProject +Project("{39E2626F-3545-4960-A6E8-258AD8476CE5}") = "InverseKinematic.Packaging", "26_InverseKinematic\InverseKinematic.Packaging\InverseKinematic.Packaging.androidproj", "{E0A67149-16F7-4531-B5FE-D14F8CB7742C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -1125,6 +1135,46 @@ Global {91917FF4-AAE0-4487-B1D1-2D09F723CEC9}.Release|x64.Build.0 = Release|x64 {91917FF4-AAE0-4487-B1D1-2D09F723CEC9}.Release|x86.ActiveCfg = Release|x86 {91917FF4-AAE0-4487-B1D1-2D09F723CEC9}.Release|x86.Build.0 = Release|x86 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|ARM.ActiveCfg = Debug|ARM + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|ARM.Build.0 = Debug|ARM + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|ARM64.Build.0 = Debug|ARM64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|x64.ActiveCfg = Debug|x64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|x64.Build.0 = Debug|x64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|x86.ActiveCfg = Debug|x86 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Debug|x86.Build.0 = Debug|x86 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|ARM.ActiveCfg = Release|ARM + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|ARM.Build.0 = Release|ARM + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|ARM64.ActiveCfg = Release|ARM64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|ARM64.Build.0 = Release|ARM64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|x64.ActiveCfg = Release|x64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|x64.Build.0 = Release|x64 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|x86.ActiveCfg = Release|x86 + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2}.Release|x86.Build.0 = Release|x86 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|ARM.ActiveCfg = Debug|ARM + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|ARM.Build.0 = Debug|ARM + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|ARM.Deploy.0 = Debug|ARM + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|ARM64.Build.0 = Debug|ARM64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|ARM64.Deploy.0 = Debug|ARM64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|x64.ActiveCfg = Debug|x64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|x64.Build.0 = Debug|x64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|x64.Deploy.0 = Debug|x64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|x86.ActiveCfg = Debug|x86 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|x86.Build.0 = Debug|x86 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Debug|x86.Deploy.0 = Debug|x86 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|ARM.ActiveCfg = Release|ARM + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|ARM.Build.0 = Release|ARM + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|ARM.Deploy.0 = Release|ARM + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|ARM64.ActiveCfg = Release|ARM64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|ARM64.Build.0 = Release|ARM64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|ARM64.Deploy.0 = Release|ARM64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|x64.ActiveCfg = Release|x64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|x64.Build.0 = Release|x64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|x64.Deploy.0 = Release|x64 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|x86.ActiveCfg = Release|x86 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|x86.Build.0 = Release|x86 + {E0A67149-16F7-4531-B5FE-D14F8CB7742C}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1196,6 +1246,9 @@ Global {68F48840-8AFC-444F-B7CA-96905009D8E6} = {A37A5CB9-8C24-4078-AA5A-B39C432659E1} {7F731144-580B-423B-B808-A3B42A9C662B} = {53B8EEA8-D0FA-4F02-B40E-CD648E0808F3} {91917FF4-AAE0-4487-B1D1-2D09F723CEC9} = {53B8EEA8-D0FA-4F02-B40E-CD648E0808F3} + {35AB2208-85FF-4E42-A583-8281E7756712} = {5CE35AF5-D486-4F3F-BF64-92F63A59910C} + {6A5D203F-5617-4CD2-BFC3-17B01740BBF2} = {35AB2208-85FF-4E42-A583-8281E7756712} + {E0A67149-16F7-4531-B5FE-D14F8CB7742C} = {35AB2208-85FF-4E42-A583-8281E7756712} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {1AC8F675-BFAF-464F-891F-048A17AFA1E4} diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/08_GltfViewer.vcxproj b/Examples_3/Unit_Tests/PC Visual Studio 2017/08_GltfViewer.vcxproj index ff3af3f072..73401fb9b7 100644 --- a/Examples_3/Unit_Tests/PC Visual Studio 2017/08_GltfViewer.vcxproj +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/08_GltfViewer.vcxproj @@ -140,14 +140,14 @@ true $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(IncludePath) - $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) + $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) $(SolutionDir)$(Platform)\$(Configuration)\ true $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(IncludePath) - $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) + $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) $(SolutionDir)$(Platform)\$(Configuration)\ @@ -161,14 +161,14 @@ false $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(IncludePath) - $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) + $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) $(SolutionDir)$(Platform)\$(Configuration)\ false $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ $(IncludePath) - $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) + $(SolutionDir)\$(Platform)\$(Configuration);$(ProjectDir)..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\Win64\Bin\$(Configuration);$(LibraryPath);$(SolutionDir)\..\..\..\Common_3\Tools\AssetLoader\Win64\x64\$(Configuration) $(SolutionDir)$(Platform)\$(Configuration)\ @@ -190,7 +190,7 @@ /ENTRY:mainCRTStartup %(AdditionalOptions) mainCRTStartup $(GLFW_DIR)\lib - Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;vulkan-1.lib;SpirvTools.lib;RendererVulkan.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) + ozz_base.lib;ozz_animation.lib;Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;vulkan-1.lib;SpirvTools.lib;RendererVulkan.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) PerMonitorHighDPIAware @@ -231,7 +231,7 @@ /ENTRY:mainCRTStartup %(AdditionalOptions) mainCRTStartup $(GLFW_DIR)\lib - Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX12.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) + ozz_base.lib;ozz_animation.lib;Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX12.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) @@ -273,7 +273,7 @@ /ENTRY:mainCRTStartup %(AdditionalOptions) mainCRTStartup $(GLFW_DIR)\lib - Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX11.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) + ozz_base.lib;ozz_animation.lib;Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX11.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) @@ -318,7 +318,7 @@ mainCRTStartup /ENTRY:mainCRTStartup %(AdditionalOptions) $(GLFW_DIR)\lib - Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;vulkan-1.lib;SpirvTools.lib;RendererVulkan.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) + ozz_base.lib;ozz_animation.lib;Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;vulkan-1.lib;SpirvTools.lib;RendererVulkan.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) PerMonitorHighDPIAware @@ -363,7 +363,7 @@ mainCRTStartup /ENTRY:mainCRTStartup %(AdditionalOptions) $(GLFW_DIR)\lib - Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX12.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) + ozz_base.lib;ozz_animation.lib;Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX12.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) @@ -409,7 +409,7 @@ mainCRTStartup /ENTRY:mainCRTStartup %(AdditionalOptions) $(GLFW_DIR)\lib - Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX11.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) + ozz_base.lib;ozz_animation.lib;Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;AssetPipeline.lib;MeshOptimizer.lib;RendererDX11.lib;OS.lib;MeshOptimizer.lib;AssetPipeline.lib;%(AdditionalDependencies) diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/25_Skinning.vcxproj b/Examples_3/Unit_Tests/PC Visual Studio 2017/25_Skinning.vcxproj index 127460a601..d4ff962574 100644 --- a/Examples_3/Unit_Tests/PC Visual Studio 2017/25_Skinning.vcxproj +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/25_Skinning.vcxproj @@ -91,6 +91,7 @@ EnableFastChecks MultiThreadedDebugDLL $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + true Windows @@ -125,6 +126,7 @@ USE_MEMORY_TRACKING;_DEBUG;_WINDOWS;VULKAN;%(PreprocessorDefinitions) $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) MultiThreadedDebugDLL + true Windows @@ -157,6 +159,7 @@ true NDEBUG;_WINDOWS;DIRECT3D12;%(PreprocessorDefinitions) $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + true Windows @@ -188,6 +191,7 @@ Classic NDEBUG;_WINDOWS;VULKAN;%(PreprocessorDefinitions) $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + true Windows diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/26_InverseKinematic.vcxproj b/Examples_3/Unit_Tests/PC Visual Studio 2017/26_InverseKinematic.vcxproj new file mode 100644 index 0000000000..8daf77ce5a --- /dev/null +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/26_InverseKinematic.vcxproj @@ -0,0 +1,213 @@ + + + + + DebugDx + x64 + + + DebugVk + x64 + + + ReleaseDx + x64 + + + ReleaseVk + x64 + + + + 15.0 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE} + My01Playback + 10.0.17763.0 + + + + v141 + Unicode + + + v141 + Unicode + true + + + v141 + Unicode + true + + + v141 + Unicode + + + + + + + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(IncludePath) + $(SolutionDir)\$(Platform)\$(Configuration);$(LibraryPath) + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VULKAN_SDK)\Include;$(IncludePath) + $(SolutionDir)\$(Platform)\$(Configuration);$(VULKAN_SDK)\Lib;$(LibraryPath) + true + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(IncludePath) + $(SolutionDir)\$(Platform)\$(Configuration);$(LibraryPath) + false + + + $(SolutionDir)\$(Platform)\$(Configuration)\Intermediate\$(ProjectName)\ + $(VULKAN_SDK)\Include;$(IncludePath) + $(SolutionDir)\$(Platform)\$(Configuration);$(VULKAN_SDK)\Lib;$(LibraryPath) + false + + + + EditAndContinue + + + + + Level3 + + + + + true + Disabled + USE_MEMORY_TRACKING;_DEBUG;_WINDOWS;DIRECT3D12;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebugDLL + $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + true + + + Windows + $(GLFW_DIR)\lib + Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;ozz_base.lib;ozz_animation.lib;RendererDX12.lib;OS.lib;%(AdditionalDependencies); + true + mainCRTStartup + + + PerMonitorHighDPIAware + $(IntDir)$(TargetName)$(TargetExt).embed.manifest + + + $(IntDir)$(TargetName)$(TargetExt).embed.manifest.res + + + + + Level3 + + + + + true + EnableFastChecks + EditAndContinue + Disabled + USE_MEMORY_TRACKING;_DEBUG;_WINDOWS;VULKAN;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + MultiThreadedDebugDLL + true + + + Windows + $(GLFW_DIR)\lib + Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;ozz_base.lib;ozz_animation.lib;vulkan-1.lib;SpirvTools.lib;RendererVulkan.lib;OS.lib;%(AdditionalDependencies) + true + mainCRTStartup + + + PerMonitorHighDPIAware + $(IntDir)$(TargetName)$(TargetExt).embed.manifest + + + $(IntDir)$(TargetName)$(TargetExt).embed.manifest.res + + + + + Level3 + + + + + true + true + true + NDEBUG;_WINDOWS;DIRECT3D12;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + true + + + Windows + true + $(GLFW_DIR)\lib + Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;ozz_base.lib;ozz_animation.lib;RendererDX12.lib;OS.lib;%(AdditionalDependencies); + true + true + mainCRTStartup + + + PerMonitorHighDPIAware + + + + + Level3 + + + + + true + true + true + Classic + NDEBUG;_WINDOWS;VULKAN;%(PreprocessorDefinitions) + $(SolutionDir)..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\include;%(AdditionalIncludeDirectories) + true + + + Windows + true + $(GLFW_DIR)\lib + Xinput9_1_0.lib;ws2_32.lib;gainputstatic.lib;ozz_base.lib;ozz_animation.lib;vulkan-1.lib;SpirvTools.lib;RendererVulkan.lib;OS.lib;%(AdditionalDependencies); + true + true + mainCRTStartup + + + PerMonitorHighDPIAware + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/26_InverseKinematic.vcxproj.filters b/Examples_3/Unit_Tests/PC Visual Studio 2017/26_InverseKinematic.vcxproj.filters new file mode 100644 index 0000000000..cf9955285f --- /dev/null +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/26_InverseKinematic.vcxproj.filters @@ -0,0 +1,49 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {0f7c17de-097d-4975-9115-6acd59ae682c} + + + {144cf7a6-3889-40ef-b7b7-9e22f787d84f} + + + {37f3928e-8d58-4486-803e-6d324993a412} + + + + + Shaders\Vulkan + + + Shaders\Vulkan + + + Shaders\Vulkan + + + Shaders\Vulkan + + + Shaders\D3D12 + + + Shaders\D3D12 + + + Shaders\D3D12 + + + Shaders\D3D12 + + + + + Source Files + + + \ No newline at end of file diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/26_Audio.vcxproj b/Examples_3/Unit_Tests/PC Visual Studio 2017/27_Audio.vcxproj similarity index 99% rename from Examples_3/Unit_Tests/PC Visual Studio 2017/26_Audio.vcxproj rename to Examples_3/Unit_Tests/PC Visual Studio 2017/27_Audio.vcxproj index e3599d6f4d..8cb61f3efe 100644 --- a/Examples_3/Unit_Tests/PC Visual Studio 2017/26_Audio.vcxproj +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/27_Audio.vcxproj @@ -73,7 +73,7 @@ - + diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/26_Audio.vcxproj.filters b/Examples_3/Unit_Tests/PC Visual Studio 2017/27_Audio.vcxproj.filters similarity index 99% rename from Examples_3/Unit_Tests/PC Visual Studio 2017/26_Audio.vcxproj.filters rename to Examples_3/Unit_Tests/PC Visual Studio 2017/27_Audio.vcxproj.filters index 46e6f42ddd..fb8ca2c482 100644 --- a/Examples_3/Unit_Tests/PC Visual Studio 2017/26_Audio.vcxproj.filters +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/27_Audio.vcxproj.filters @@ -15,7 +15,7 @@ - + Source Files diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/Libraries/Tools/LuaManager.vcxproj b/Examples_3/Unit_Tests/PC Visual Studio 2017/Libraries/Tools/LuaManager.vcxproj index fabfbc2e4b..a2c90cc039 100644 --- a/Examples_3/Unit_Tests/PC Visual Studio 2017/Libraries/Tools/LuaManager.vcxproj +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/Libraries/Tools/LuaManager.vcxproj @@ -209,7 +209,8 @@ %(AdditionalDependencies) - OS.lib + + @@ -233,7 +234,8 @@ %(AdditionalDependencies) - OS.lib + + @@ -257,7 +259,8 @@ %(AdditionalDependencies) - OS.lib + + @@ -285,7 +288,8 @@ %(AdditionalDependencies) - OS.lib + + @@ -313,7 +317,8 @@ %(AdditionalDependencies) - OS.lib + + @@ -341,7 +346,8 @@ %(AdditionalDependencies) - OS.lib + + diff --git a/Examples_3/Unit_Tests/PC Visual Studio 2017/Unit_Tests.sln b/Examples_3/Unit_Tests/PC Visual Studio 2017/Unit_Tests.sln index 52bb66e132..6e4009ab6f 100644 --- a/Examples_3/Unit_Tests/PC Visual Studio 2017/Unit_Tests.sln +++ b/Examples_3/Unit_Tests/PC Visual Studio 2017/Unit_Tests.sln @@ -220,6 +220,9 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ozz-animation", "ozz-animation", "{9ED95EE6-DA38-473E-9346-84061786CDDC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozz_base", "..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\Win64\src\base\ozz_base.vcxproj", "{EE1F0FC8-40F5-476A-8553-C8175B343BEE}" + ProjectSection(ProjectDependencies) = postProject + {30DD3D57-0026-48C8-BFD1-6392F319E23A} = {30DD3D57-0026-48C8-BFD1-6392F319E23A} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozz_animation", "..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\Win64\src\animation\runtime\ozz_animation.vcxproj", "{E0CB3186-0614-4DF0-891B-848743572AB2}" EndProject @@ -333,7 +336,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "25_Skinning", "25_Skinning. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ozz_animation_offline", "..\..\..\Common_3\ThirdParty\OpenSource\ozz-animation\Win64\src\animation\offline\ozz_animation_offline.vcxproj", "{AC91B515-5B5E-399D-BF31-B6272AF9D139}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "26_Audio", "26_Audio.vcxproj", "{9E3FF620-A4E1-421B-8869-57551145772E}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "27_Audio", "27_Audio.vcxproj", "{9E3FF620-A4E1-421B-8869-57551145772E}" ProjectSection(ProjectDependencies) = postProject {DFAAEF2D-9A5E-475E-86BA-59529DD39CF3} = {DFAAEF2D-9A5E-475E-86BA-59529DD39CF3} {8EBB17A6-12AC-46AF-AE55-A7159C9CD2E1} = {8EBB17A6-12AC-46AF-AE55-A7159C9CD2E1} @@ -343,6 +346,7 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetPipelineCmd", "..\..\..\Common_3\Tools\AssetPipeline\Win64\AssetPipelineCmd.vcxproj", "{9BB45EC2-8F3A-4D98-A235-40EBBB559F64}" ProjectSection(ProjectDependencies) = postProject {D89F2A05-407F-427F-BD64-B9AAC130E604} = {D89F2A05-407F-427F-BD64-B9AAC130E604} + {59586A07-8E7E-411D-BC3D-387E039AA423} = {59586A07-8E7E-411D-BC3D-387E039AA423} {AC91B515-5B5E-399D-BF31-B6272AF9D139} = {AC91B515-5B5E-399D-BF31-B6272AF9D139} {29449326-FEDE-40D1-B849-536BD8E58041} = {29449326-FEDE-40D1-B849-536BD8E58041} {86CCE738-AAA1-4327-9DE0-AAB5B23B7852} = {86CCE738-AAA1-4327-9DE0-AAB5B23B7852} @@ -366,6 +370,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AssetPipeline", "..\..\..\C EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MeshOptimizer", "..\..\..\Common_3\ThirdParty\OpenSource\meshoptimizer\Win64\MeshOptimizer.vcxproj", "{D89F2A05-407F-427F-BD64-B9AAC130E604}" + ProjectSection(ProjectDependencies) = postProject + {30DD3D57-0026-48C8-BFD1-6392F319E23A} = {30DD3D57-0026-48C8-BFD1-6392F319E23A} + EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "08_GltfViewer", "08_GltfViewer.vcxproj", "{72714A3C-1FFA-412F-A6B0-130550B1DD2C}" ProjectSection(ProjectDependencies) = postProject @@ -375,7 +382,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "08_GltfViewer", "08_GltfVie {86CCE738-AAA1-4327-9DE0-AAB5B23B7852} = {86CCE738-AAA1-4327-9DE0-AAB5B23B7852} {30DD3D57-0026-48C8-BFD1-6392F319E23A} = {30DD3D57-0026-48C8-BFD1-6392F319E23A} {8EBB17A6-12AC-46AF-AE55-A7159C9CD2E1} = {8EBB17A6-12AC-46AF-AE55-A7159C9CD2E1} - {9BB45EC2-8F3A-4D98-A235-40EBBB559F64} = {9BB45EC2-8F3A-4D98-A235-40EBBB559F64} + {EBC1C8D7-D49B-409A-A575-5AB53111E4D7} = {EBC1C8D7-D49B-409A-A575-5AB53111E4D7} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basisu", "..\..\..\Common_3\ThirdParty\OpenSource\basis_universal\basisu.vcxproj", "{59586A07-8E7E-411D-BC3D-387E039AA423}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "26_InverseKinematic", "26_InverseKinematic.vcxproj", "{5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}" + ProjectSection(ProjectDependencies) = postProject + {DFAAEF2D-9A5E-475E-86BA-59529DD39CF3} = {DFAAEF2D-9A5E-475E-86BA-59529DD39CF3} + {C5D0E437-7C52-3132-80E6-3CBE834313EF} = {C5D0E437-7C52-3132-80E6-3CBE834313EF} + {30DD3D57-0026-48C8-BFD1-6392F319E23A} = {30DD3D57-0026-48C8-BFD1-6392F319E23A} + {F3C4507C-E714-4773-AF45-5FA9FB0BB4AF} = {F3C4507C-E714-4773-AF45-5FA9FB0BB4AF} + {E0CB3186-0614-4DF0-891B-848743572AB2} = {E0CB3186-0614-4DF0-891B-848743572AB2} + {EE1F0FC8-40F5-476A-8553-C8175B343BEE} = {EE1F0FC8-40F5-476A-8553-C8175B343BEE} {EBC1C8D7-D49B-409A-A575-5AB53111E4D7} = {EBC1C8D7-D49B-409A-A575-5AB53111E4D7} EndProjectSection EndProject @@ -1093,7 +1112,8 @@ Global {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx|x64.ActiveCfg = DebugDx|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx|x64.Build.0 = DebugDx|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx|x86.ActiveCfg = DebugDx|x64 - {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx11|x64.ActiveCfg = DebugDx|x64 + {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx11|x64.ActiveCfg = DebugDx11|x64 + {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx11|x64.Build.0 = DebugDx11|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx11|x86.ActiveCfg = ReleaseVk|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugDx11|x86.Build.0 = ReleaseVk|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.DebugVk|x64.ActiveCfg = DebugVk|x64 @@ -1102,7 +1122,8 @@ Global {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx|x64.ActiveCfg = ReleaseDx|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx|x86.ActiveCfg = ReleaseDx|x64 - {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx11|x64.ActiveCfg = ReleaseDx|x64 + {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx11|x64.ActiveCfg = ReleaseDx11|x64 + {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx11|x64.Build.0 = ReleaseDx11|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx11|x86.ActiveCfg = ReleaseVk|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseDx11|x86.Build.0 = ReleaseVk|x64 {AC91B515-5B5E-399D-BF31-B6272AF9D139}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 @@ -1130,8 +1151,8 @@ Global {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx|x64.Build.0 = DebugDx|x64 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx|x86.ActiveCfg = DebugDx|Win32 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx|x86.Build.0 = DebugDx|Win32 - {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx11|x64.ActiveCfg = DebugDx|x64 - {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx11|x64.Build.0 = DebugDx|x64 + {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx11|x64.ActiveCfg = DebugDx11|x64 + {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx11|x64.Build.0 = DebugDx11|x64 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx11|x86.ActiveCfg = DebugDx|Win32 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugDx11|x86.Build.0 = DebugDx|Win32 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.DebugVk|x64.ActiveCfg = DebugVk|x64 @@ -1142,8 +1163,7 @@ Global {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx|x86.ActiveCfg = ReleaseDx|Win32 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx|x86.Build.0 = ReleaseDx|Win32 - {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx11|x64.ActiveCfg = ReleaseDx|x64 - {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx11|x64.Build.0 = ReleaseDx|x64 + {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx11|x64.ActiveCfg = ReleaseDx11|x64 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx11|x86.ActiveCfg = ReleaseDx|Win32 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseDx11|x86.Build.0 = ReleaseDx|Win32 {9BB45EC2-8F3A-4D98-A235-40EBBB559F64}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 @@ -1153,8 +1173,8 @@ Global {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx|x64.ActiveCfg = DebugDx|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx|x64.Build.0 = DebugDx|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx|x86.ActiveCfg = DebugDx|x64 - {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx11|x64.ActiveCfg = DebugDx|x64 - {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx11|x64.Build.0 = DebugDx|x64 + {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx11|x64.ActiveCfg = DebugDx11|x64 + {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx11|x64.Build.0 = DebugDx11|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx11|x86.ActiveCfg = ReleaseVk|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugDx11|x86.Build.0 = ReleaseVk|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.DebugVk|x64.ActiveCfg = DebugVk|x64 @@ -1163,8 +1183,7 @@ Global {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx|x64.ActiveCfg = ReleaseDx|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx|x86.ActiveCfg = ReleaseDx|x64 - {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx11|x64.ActiveCfg = ReleaseDx|x64 - {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx11|x64.Build.0 = ReleaseDx|x64 + {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx11|x64.ActiveCfg = ReleaseDx11|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx11|x86.ActiveCfg = ReleaseVk|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseDx11|x86.Build.0 = ReleaseVk|x64 {86CCE738-AAA1-4327-9DE0-AAB5B23B7852}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 @@ -1204,6 +1223,48 @@ Global {72714A3C-1FFA-412F-A6B0-130550B1DD2C}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 {72714A3C-1FFA-412F-A6B0-130550B1DD2C}.ReleaseVk|x64.Build.0 = ReleaseVk|x64 {72714A3C-1FFA-412F-A6B0-130550B1DD2C}.ReleaseVk|x86.ActiveCfg = ReleaseVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x64.ActiveCfg = DebugDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x64.Build.0 = DebugDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x86.ActiveCfg = DebugDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx|x86.Build.0 = DebugDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x64.ActiveCfg = DebugDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x64.Build.0 = DebugDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x86.ActiveCfg = DebugDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugDx11|x86.Build.0 = DebugDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x64.ActiveCfg = DebugVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x64.Build.0 = DebugVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x86.ActiveCfg = DebugVk|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.DebugVk|x86.Build.0 = DebugVk|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x64.ActiveCfg = ReleaseDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x86.ActiveCfg = ReleaseDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx|x86.Build.0 = ReleaseDx|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x64.ActiveCfg = ReleaseDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x64.Build.0 = ReleaseDx11|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x86.ActiveCfg = ReleaseDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseDx11|x86.Build.0 = ReleaseDx11|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x64.Build.0 = ReleaseVk|x64 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x86.ActiveCfg = ReleaseVk|Win32 + {59586A07-8E7E-411D-BC3D-387E039AA423}.ReleaseVk|x86.Build.0 = ReleaseVk|Win32 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugDx|x64.ActiveCfg = DebugDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugDx|x64.Build.0 = DebugDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugDx|x86.ActiveCfg = DebugDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugDx11|x64.ActiveCfg = DebugDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugDx11|x86.ActiveCfg = ReleaseVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugDx11|x86.Build.0 = ReleaseVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugVk|x64.ActiveCfg = DebugVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugVk|x64.Build.0 = DebugVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.DebugVk|x86.ActiveCfg = DebugVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseDx|x64.ActiveCfg = ReleaseDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseDx|x64.Build.0 = ReleaseDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseDx|x86.ActiveCfg = ReleaseDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseDx11|x64.ActiveCfg = ReleaseDx|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseDx11|x86.ActiveCfg = ReleaseVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseDx11|x86.Build.0 = ReleaseVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseVk|x64.ActiveCfg = ReleaseVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseVk|x64.Build.0 = ReleaseVk|x64 + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE}.ReleaseVk|x86.ActiveCfg = ReleaseVk|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1255,6 +1316,8 @@ Global {86CCE738-AAA1-4327-9DE0-AAB5B23B7852} = {21A6980D-04AA-430D-BE3D-74F151226C8B} {D89F2A05-407F-427F-BD64-B9AAC130E604} = {21A6980D-04AA-430D-BE3D-74F151226C8B} {72714A3C-1FFA-412F-A6B0-130550B1DD2C} = {6CF62059-3AC3-43CD-A29E-2F1E01EA4115} + {59586A07-8E7E-411D-BC3D-387E039AA423} = {21A6980D-04AA-430D-BE3D-74F151226C8B} + {5C0F80A1-0D6A-4D17-A20B-A430B6F5DCAE} = {28423D1E-F232-4C3F-9872-F24CFC9D8493} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {948F21A0-5B36-35C9-B219-88B1DAC0D0C2} diff --git a/Examples_3/Unit_Tests/UbuntuCodelite/26_InverseKinematic/26_InverseKinematic.project b/Examples_3/Unit_Tests/UbuntuCodelite/26_InverseKinematic/26_InverseKinematic.project new file mode 100644 index 0000000000..5c3fabbd23 --- /dev/null +++ b/Examples_3/Unit_Tests/UbuntuCodelite/26_InverseKinematic/26_InverseKinematic.project @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + None + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/UbuntuCodelite/26_Audio/26_Audio.project b/Examples_3/Unit_Tests/UbuntuCodelite/27_Audio/27_Audio.project similarity index 99% rename from Examples_3/Unit_Tests/UbuntuCodelite/26_Audio/26_Audio.project rename to Examples_3/Unit_Tests/UbuntuCodelite/27_Audio/27_Audio.project index 6912a39da3..fc9e20a3ee 100644 --- a/Examples_3/Unit_Tests/UbuntuCodelite/26_Audio/26_Audio.project +++ b/Examples_3/Unit_Tests/UbuntuCodelite/27_Audio/27_Audio.project @@ -1,5 +1,5 @@ - + @@ -65,7 +65,7 @@ - + diff --git a/Examples_3/Unit_Tests/UbuntuCodelite/UbuntuUnitTests.workspace b/Examples_3/Unit_Tests/UbuntuCodelite/UbuntuUnitTests.workspace index c06ea6967d..01da91bb88 100644 --- a/Examples_3/Unit_Tests/UbuntuCodelite/UbuntuUnitTests.workspace +++ b/Examples_3/Unit_Tests/UbuntuCodelite/UbuntuUnitTests.workspace @@ -35,11 +35,12 @@ - + + @@ -80,12 +81,13 @@ - - + + + @@ -100,8 +102,8 @@ - - + + @@ -130,6 +132,7 @@ + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.pbxproj b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..2307a9e802 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.pbxproj @@ -0,0 +1,937 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 5B17817522A5C85F00991DCB /* profile.frag.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5B17817122A5C85F00991DCB /* profile.frag.metal */; }; + 5B17817622A5C85F00991DCB /* profile.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5B17817422A5C85F00991DCB /* profile.vert.metal */; }; + 5CA810AE21F0A36000C99983 /* fontstash.frag.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8102221F0A2CA00C99983 /* fontstash.frag.metal */; }; + 5CA810AF21F0A36000C99983 /* fontstash2D.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8102121F0A2CA00C99983 /* fontstash2D.vert.metal */; }; + 5CA810B021F0A36000C99983 /* fontstash3D.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8102021F0A2CA00C99983 /* fontstash3D.vert.metal */; }; + 5CA810B121F0A36000C99983 /* imgui.frag.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8101621F0A2C300C99983 /* imgui.frag.metal */; }; + 5CA810B221F0A36000C99983 /* imgui.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8101721F0A2C300C99983 /* imgui.vert.metal */; }; + 5CA810B321F0A36000C99983 /* textured_mesh.frag.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8101521F0A2C300C99983 /* textured_mesh.frag.metal */; }; + 5CA810B421F0A36000C99983 /* textured_mesh.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5CA8101421F0A2C300C99983 /* textured_mesh.vert.metal */; }; + 650CCC862223CEFE003533D9 /* MetalPerformanceShaders.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 650CCC832223CEFE003533D9 /* MetalPerformanceShaders.framework */; }; + 650CCC882223CF17003533D9 /* MetalPerformanceShaders.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 650CCC872223CF17003533D9 /* MetalPerformanceShaders.framework */; }; + B214AD3320E2DD620025F76B /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B214AD3120E2DD620025F76B /* Metal.framework */; }; + B214AD3420E2DD620025F76B /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B214AD3220E2DD620025F76B /* MetalKit.framework */; }; + B22D906920E2EDCE0036B88E /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22D906220E2EDCE0036B88E /* Metal.framework */; }; + B22D906A20E2EDCE0036B88E /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B22D906820E2EDCE0036B88E /* MetalKit.framework */; }; + B2541CFD21751B5B00F702BB /* libThe-Forge_iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B2541CFC21751B4E00F702BB /* libThe-Forge_iOS.a */; }; + B2541CFE21751B6200F702BB /* libThe-Forge.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B2541CFA21751B4E00F702BB /* libThe-Forge.a */; }; + B27D879A20E2E88B00081DB0 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B27D879920E2E88B00081DB0 /* GameController.framework */; }; + B2B73FC721754A3B00324803 /* 26_InverseKinematic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2B73FC621754A3B00324803 /* 26_InverseKinematic.cpp */; }; + B2B73FE421754CB400324803 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B73FE221754CB400324803 /* AppDelegate.m */; }; + B2B73FEA2175504F00324803 /* 26_InverseKinematic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2B73FC621754A3B00324803 /* 26_InverseKinematic.cpp */; }; + B2B7400F2175533E00324803 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B7400E2175533E00324803 /* AppDelegate.m */; }; + B2B740162175553800324803 /* TitilliumText in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B740152175553800324803 /* TitilliumText */; }; + B2B740222175571D00324803 /* stickFigure in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B740212175571C00324803 /* stickFigure */; }; + B2B7405F21755BF800324803 /* basic.frag.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B7405921755BE100324803 /* basic.frag.metal */; }; + B2B7406021755BF800324803 /* basic.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B7405A21755BE100324803 /* basic.vert.metal */; }; + B2B7406121755BF800324803 /* plane.frag.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B7405821755BE100324803 /* plane.frag.metal */; }; + B2B7406221755BF800324803 /* plane.vert.metal in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B7405721755BE100324803 /* plane.vert.metal */; }; + B2B7406B21755F1200324803 /* circlepad.ktx in Resources */ = {isa = PBXBuildFile; fileRef = B2B7406A21755F1200324803 /* circlepad.ktx */; }; + B2B7406C21755F2C00324803 /* circlepad.ktx in CopyFiles */ = {isa = PBXBuildFile; fileRef = B2B7406A21755F1200324803 /* circlepad.ktx */; }; + B2C44078211E2563008F57D5 /* ozz_animation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B23FA458211E24F70059929A /* ozz_animation.a */; }; + B2C44079211E2563008F57D5 /* ozz_base.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B23FA45C211E24F70059929A /* ozz_base.a */; }; + B2D1CEB420EAECDB001BB8C4 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2D1CEB320EAECDB001BB8C4 /* UIKit.framework */; }; + C95132FF2010E68A002E584B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C95132FE2010E68A002E584B /* Assets.xcassets */; }; + D0296BEC211EE433000C9281 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D0296BEA211EE433000C9281 /* LaunchScreen.storyboard */; }; + D0796AEA211ED7A70028AFFD /* ozz_animation_IOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0796AE7211ED7950028AFFD /* ozz_animation_IOS.a */; }; + D0796AEB211ED7A70028AFFD /* ozz_base_IOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D0796AE9211ED7950028AFFD /* ozz_base_IOS.a */; }; + D28782F01F0A7F52004DC624 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D28782EF1F0A7F52004DC624 /* Assets.xcassets */; }; + D2E631E11F3472DF005BFBA7 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = D2E631DF1F3472DF005BFBA7 /* MainMenu.xib */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 5CA80FDD21F0A28A00C99983 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = B28C6EEE21B209AA00FBA1BF; + remoteInfo = "ozz_animation offline"; + }; + B23FA455211E24F70059929A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 88DF3489E6364B89869CC71D; + remoteInfo = json; + }; + B23FA457211E24F70059929A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = AD14F53CA01347BBA91C7F42; + remoteInfo = ozz_animation; + }; + B23FA45B211E24F70059929A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = A69A1ECFEC9145D3A46BAA96; + remoteInfo = ozz_base; + }; + B2541CF921751B4E00F702BB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 5C5582E021413D180019960B; + remoteInfo = "The-Forge"; + }; + B2541CFB21751B4E00F702BB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 5C172FC821414C490074EE71; + remoteInfo = "The-Forge_iOS"; + }; + B2541CFF21751B6B00F702BB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 5C5582DF21413D180019960B; + remoteInfo = "The-Forge"; + }; + B2541D0121751B6F00F702BB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 5C172FC721414C490074EE71; + remoteInfo = "The-Forge_iOS"; + }; + B2C4406F211E254B008F57D5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = B578F05FA1304339B5CEB8AB; + remoteInfo = ozz_animation; + }; + B2C44071211E254B008F57D5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = ECEC0611C3BB4CAF82DAF102; + remoteInfo = ozz_base; + }; + D0796ADF211ED7950028AFFD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D0796ABD211ED7370028AFFD; + remoteInfo = ozz_animation_IOS; + }; + D0796AE1211ED7950028AFFD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = D0796ACE211ED7430028AFFD; + remoteInfo = ozz_base_IOS; + }; + D0796AE6211ED7950028AFFD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D0796ACD211ED7370028AFFD; + remoteInfo = ozz_animation_IOS; + }; + D0796AE8211ED7950028AFFD /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = D0796ADE211ED7430028AFFD; + remoteInfo = ozz_base_IOS; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + B2B740102175546000324803 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Fonts; + dstSubfolderSpec = 7; + files = ( + B2B740162175553800324803 /* TitilliumText in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B2B740172175554200324803 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Textures; + dstSubfolderSpec = 7; + files = ( + B2B7406C21755F2C00324803 /* circlepad.ktx in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B2B74019217555AB00324803 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Shaders/Metal; + dstSubfolderSpec = 7; + files = ( + 5B17817522A5C85F00991DCB /* profile.frag.metal in CopyFiles */, + 5B17817622A5C85F00991DCB /* profile.vert.metal in CopyFiles */, + 5CA810AE21F0A36000C99983 /* fontstash.frag.metal in CopyFiles */, + 5CA810AF21F0A36000C99983 /* fontstash2D.vert.metal in CopyFiles */, + 5CA810B021F0A36000C99983 /* fontstash3D.vert.metal in CopyFiles */, + 5CA810B121F0A36000C99983 /* imgui.frag.metal in CopyFiles */, + 5CA810B221F0A36000C99983 /* imgui.vert.metal in CopyFiles */, + 5CA810B321F0A36000C99983 /* textured_mesh.frag.metal in CopyFiles */, + 5CA810B421F0A36000C99983 /* textured_mesh.vert.metal in CopyFiles */, + B2B7405F21755BF800324803 /* basic.frag.metal in CopyFiles */, + B2B7406021755BF800324803 /* basic.vert.metal in CopyFiles */, + B2B7406121755BF800324803 /* plane.frag.metal in CopyFiles */, + B2B7406221755BF800324803 /* plane.vert.metal in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + B2B7401E217556D100324803 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Animation; + dstSubfolderSpec = 7; + files = ( + B2B740222175571D00324803 /* stickFigure in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 5B17817122A5C85F00991DCB /* profile.frag.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; name = profile.frag.metal; path = ../../src/18_Playback/Shaders/Metal/profile.frag.metal; sourceTree = ""; }; + 5B17817422A5C85F00991DCB /* profile.vert.metal */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.metal; name = profile.vert.metal; path = ../../src/18_Playback/Shaders/Metal/profile.vert.metal; sourceTree = ""; }; + 5CA8101421F0A2C300C99983 /* textured_mesh.vert.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = textured_mesh.vert.metal; path = ../../../../Middleware_3/UI/Shaders/Metal/textured_mesh.vert.metal; sourceTree = ""; }; + 5CA8101521F0A2C300C99983 /* textured_mesh.frag.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = textured_mesh.frag.metal; path = ../../../../Middleware_3/UI/Shaders/Metal/textured_mesh.frag.metal; sourceTree = ""; }; + 5CA8101621F0A2C300C99983 /* imgui.frag.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = imgui.frag.metal; path = ../../../../Middleware_3/UI/Shaders/Metal/imgui.frag.metal; sourceTree = ""; }; + 5CA8101721F0A2C300C99983 /* imgui.vert.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = imgui.vert.metal; path = ../../../../Middleware_3/UI/Shaders/Metal/imgui.vert.metal; sourceTree = ""; }; + 5CA8102021F0A2CA00C99983 /* fontstash3D.vert.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = fontstash3D.vert.metal; path = ../../../../Middleware_3/Text/Shaders/Metal/fontstash3D.vert.metal; sourceTree = ""; }; + 5CA8102121F0A2CA00C99983 /* fontstash2D.vert.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = fontstash2D.vert.metal; path = ../../../../Middleware_3/Text/Shaders/Metal/fontstash2D.vert.metal; sourceTree = ""; }; + 5CA8102221F0A2CA00C99983 /* fontstash.frag.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = fontstash.frag.metal; path = ../../../../Middleware_3/Text/Shaders/Metal/fontstash.frag.metal; sourceTree = ""; }; + 650CCC832223CEFE003533D9 /* MetalPerformanceShaders.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalPerformanceShaders.framework; path = System/Library/Frameworks/MetalPerformanceShaders.framework; sourceTree = SDKROOT; }; + 650CCC872223CF17003533D9 /* MetalPerformanceShaders.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalPerformanceShaders.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk/System/Library/Frameworks/MetalPerformanceShaders.framework; sourceTree = DEVELOPER_DIR; }; + B214AD3120E2DD620025F76B /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/Metal.framework; sourceTree = DEVELOPER_DIR; }; + B214AD3220E2DD620025F76B /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/MetalKit.framework; sourceTree = DEVELOPER_DIR; }; + B22D906220E2EDCE0036B88E /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; }; + B22D906820E2EDCE0036B88E /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; + B23FA44B211E24F70059929A /* ozz.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ozz.xcodeproj; path = "../../../../Common_3/ThirdParty/OpenSource/ozz-animation/MacOS/ozz.xcodeproj"; sourceTree = ""; }; + B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "The-Forge.xcodeproj"; path = "../The-Forge/The-Forge.xcodeproj"; sourceTree = ""; }; + B27D879920E2E88B00081DB0 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; }; + B2B73F1721751BF900324803 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; + B2B73FC621754A3B00324803 /* 26_InverseKinematic.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = 26_InverseKinematic.cpp; path = ../../src/26_InverseKinematic/26_InverseKinematic.cpp; sourceTree = ""; }; + B2B73FE221754CB400324803 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = ../../../../../Common_3/OS/macOS/AppDelegate.m; sourceTree = ""; }; + B2B73FE321754CB400324803 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../../../../../Common_3/OS/macOS/AppDelegate.h; sourceTree = ""; }; + B2B7400C2175532600324803 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../../../../../Common_3/OS/iOS/AppDelegate.h; sourceTree = ""; }; + B2B7400E2175533E00324803 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = ../../../../../Common_3/OS/iOS/AppDelegate.m; sourceTree = ""; }; + B2B740152175553800324803 /* TitilliumText */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TitilliumText; sourceTree = ""; }; + B2B740212175571C00324803 /* stickFigure */ = {isa = PBXFileReference; lastKnownFileType = folder; path = stickFigure; sourceTree = ""; }; + B2B7405721755BE100324803 /* plane.vert.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = plane.vert.metal; path = ../../src/18_Playback/Shaders/Metal/plane.vert.metal; sourceTree = ""; }; + B2B7405821755BE100324803 /* plane.frag.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = plane.frag.metal; path = ../../src/18_Playback/Shaders/Metal/plane.frag.metal; sourceTree = ""; }; + B2B7405921755BE100324803 /* basic.frag.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = basic.frag.metal; path = ../../src/18_Playback/Shaders/Metal/basic.frag.metal; sourceTree = ""; }; + B2B7405A21755BE100324803 /* basic.vert.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = basic.vert.metal; path = ../../src/18_Playback/Shaders/Metal/basic.vert.metal; sourceTree = ""; }; + B2B7406A21755F1200324803 /* circlepad.ktx */ = {isa = PBXFileReference; lastKnownFileType = image.ktx; path = circlepad.ktx; sourceTree = ""; }; + B2D1CEB320EAECDB001BB8C4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + C95132ED2010E68A002E584B /* 26_InverseKinematic_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 26_InverseKinematic_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C95132FE2010E68A002E584B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + C95133032010E68A002E584B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D0296BEB211EE433000C9281 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + D28782EF1F0A7F52004DC624 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = 26_InverseKinematic/Assets.xcassets; sourceTree = SOURCE_ROOT; }; + D2E631E01F3472DF005BFBA7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + EA463C8B1EF81E8F005AC8C7 /* 26_InverseKinematic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 26_InverseKinematic.app; sourceTree = BUILT_PRODUCTS_DIR; }; + EADF9D661EFD160E00B2008B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = 26_InverseKinematic/Info.plist; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C95132EA2010E68A002E584B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 650CCC882223CF17003533D9 /* MetalPerformanceShaders.framework in Frameworks */, + B2541CFD21751B5B00F702BB /* libThe-Forge_iOS.a in Frameworks */, + D0796AEA211ED7A70028AFFD /* ozz_animation_IOS.a in Frameworks */, + D0796AEB211ED7A70028AFFD /* ozz_base_IOS.a in Frameworks */, + B2D1CEB420EAECDB001BB8C4 /* UIKit.framework in Frameworks */, + B27D879A20E2E88B00081DB0 /* GameController.framework in Frameworks */, + B214AD3320E2DD620025F76B /* Metal.framework in Frameworks */, + B214AD3420E2DD620025F76B /* MetalKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EA463C881EF81E8F005AC8C7 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 650CCC862223CEFE003533D9 /* MetalPerformanceShaders.framework in Frameworks */, + B2541CFE21751B6200F702BB /* libThe-Forge.a in Frameworks */, + B2C44078211E2563008F57D5 /* ozz_animation.a in Frameworks */, + B2C44079211E2563008F57D5 /* ozz_base.a in Frameworks */, + B22D906920E2EDCE0036B88E /* Metal.framework in Frameworks */, + B22D906A20E2EDCE0036B88E /* MetalKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 28A5ABEA201F482F000E571F /* Frameworks */ = { + isa = PBXGroup; + children = ( + 650CCC832223CEFE003533D9 /* MetalPerformanceShaders.framework */, + 650CCC872223CF17003533D9 /* MetalPerformanceShaders.framework */, + B2B73F1721751BF900324803 /* GameController.framework */, + B2D1CEB320EAECDB001BB8C4 /* UIKit.framework */, + B22D906220E2EDCE0036B88E /* Metal.framework */, + B22D906820E2EDCE0036B88E /* MetalKit.framework */, + B27D879920E2E88B00081DB0 /* GameController.framework */, + B214AD3120E2DD620025F76B /* Metal.framework */, + B214AD3220E2DD620025F76B /* MetalKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 5CA80FDA21F0A28A00C99983 /* CommonShaders */ = { + isa = PBXGroup; + children = ( + 5CA8102221F0A2CA00C99983 /* fontstash.frag.metal */, + 5CA8102121F0A2CA00C99983 /* fontstash2D.vert.metal */, + 5CA8102021F0A2CA00C99983 /* fontstash3D.vert.metal */, + 5CA8101621F0A2C300C99983 /* imgui.frag.metal */, + 5CA8101721F0A2C300C99983 /* imgui.vert.metal */, + 5CA8101521F0A2C300C99983 /* textured_mesh.frag.metal */, + 5CA8101421F0A2C300C99983 /* textured_mesh.vert.metal */, + ); + name = CommonShaders; + sourceTree = ""; + }; + B23FA44C211E24F70059929A /* Products */ = { + isa = PBXGroup; + children = ( + B23FA456211E24F70059929A /* json_d.a */, + B23FA458211E24F70059929A /* ozz_animation.a */, + B23FA45C211E24F70059929A /* ozz_base.a */, + D0796AE7211ED7950028AFFD /* ozz_animation_IOS.a */, + D0796AE9211ED7950028AFFD /* ozz_base_IOS.a */, + 5CA80FDE21F0A28A00C99983 /* ozz_animation offline.a */, + ); + name = Products; + sourceTree = ""; + }; + B2541CF421751B4E00F702BB /* Products */ = { + isa = PBXGroup; + children = ( + B2541CFA21751B4E00F702BB /* libThe-Forge.a */, + B2541CFC21751B4E00F702BB /* libThe-Forge_iOS.a */, + ); + name = Products; + sourceTree = ""; + }; + B2B73F602175468A00324803 /* Fonts */ = { + isa = PBXGroup; + children = ( + B2B740152175553800324803 /* TitilliumText */, + ); + name = Fonts; + path = ../../UnitTestResources/Fonts; + sourceTree = ""; + }; + B2B73F70217546B700324803 /* Animation */ = { + isa = PBXGroup; + children = ( + B2B740212175571C00324803 /* stickFigure */, + ); + name = Animation; + path = ../../UnitTestResources/Animation; + sourceTree = ""; + }; + B2B73FC821754A5900324803 /* Textures */ = { + isa = PBXGroup; + children = ( + B2B7406A21755F1200324803 /* circlepad.ktx */, + ); + name = Textures; + path = ../../UnitTestResources/Textures; + sourceTree = ""; + }; + B2B7405621755BC200324803 /* Shaders */ = { + isa = PBXGroup; + children = ( + B2B7405921755BE100324803 /* basic.frag.metal */, + B2B7405A21755BE100324803 /* basic.vert.metal */, + B2B7405821755BE100324803 /* plane.frag.metal */, + B2B7405721755BE100324803 /* plane.vert.metal */, + ); + name = Shaders; + sourceTree = ""; + }; + C95132EE2010E68A002E584B /* 26_InverseKinematic_iOS */ = { + isa = PBXGroup; + children = ( + B2B7400E2175533E00324803 /* AppDelegate.m */, + B2B7400C2175532600324803 /* AppDelegate.h */, + C95132FE2010E68A002E584B /* Assets.xcassets */, + D0296BEA211EE433000C9281 /* LaunchScreen.storyboard */, + C95133032010E68A002E584B /* Info.plist */, + ); + path = 26_InverseKinematic_iOS; + sourceTree = ""; + }; + EA463C821EF81E8F005AC8C7 = { + isa = PBXGroup; + children = ( + 5B17817122A5C85F00991DCB /* profile.frag.metal */, + 5B17817422A5C85F00991DCB /* profile.vert.metal */, + 5CA80FDA21F0A28A00C99983 /* CommonShaders */, + B2B7405621755BC200324803 /* Shaders */, + B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */, + B23FA44B211E24F70059929A /* ozz.xcodeproj */, + B2B73F602175468A00324803 /* Fonts */, + B2B73FC821754A5900324803 /* Textures */, + B2B73F70217546B700324803 /* Animation */, + B2B73FC621754A3B00324803 /* 26_InverseKinematic.cpp */, + EA463C941EF81E8F005AC8C7 /* 26_InverseKinematic */, + C95132EE2010E68A002E584B /* 26_InverseKinematic_iOS */, + EA463C8C1EF81E8F005AC8C7 /* Products */, + 28A5ABEA201F482F000E571F /* Frameworks */, + ); + sourceTree = ""; + }; + EA463C8C1EF81E8F005AC8C7 /* Products */ = { + isa = PBXGroup; + children = ( + EA463C8B1EF81E8F005AC8C7 /* 26_InverseKinematic.app */, + C95132ED2010E68A002E584B /* 26_InverseKinematic_iOS.app */, + ); + name = Products; + sourceTree = ""; + }; + EA463C941EF81E8F005AC8C7 /* 26_InverseKinematic */ = { + isa = PBXGroup; + children = ( + B2B73FE321754CB400324803 /* AppDelegate.h */, + B2B73FE221754CB400324803 /* AppDelegate.m */, + D2E631DF1F3472DF005BFBA7 /* MainMenu.xib */, + D28782EF1F0A7F52004DC624 /* Assets.xcassets */, + EADF9D661EFD160E00B2008B /* Info.plist */, + ); + path = 26_InverseKinematic; + sourceTree = SOURCE_ROOT; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C95132EC2010E68A002E584B /* 26_InverseKinematic_iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = C95133082010E68A002E584B /* Build configuration list for PBXNativeTarget "26_InverseKinematic_iOS" */; + buildPhases = ( + C95132E92010E68A002E584B /* Sources */, + C95132EA2010E68A002E584B /* Frameworks */, + C95132EB2010E68A002E584B /* Resources */, + B2B740102175546000324803 /* CopyFiles */, + B2B740172175554200324803 /* CopyFiles */, + B2B74019217555AB00324803 /* CopyFiles */, + B2B7401E217556D100324803 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + B2541D0221751B6F00F702BB /* PBXTargetDependency */, + D0796AE0211ED7950028AFFD /* PBXTargetDependency */, + D0796AE2211ED7950028AFFD /* PBXTargetDependency */, + ); + name = 26_InverseKinematic_iOS; + productName = 01_Transformations_iOS; + productReference = C95132ED2010E68A002E584B /* 26_InverseKinematic_iOS.app */; + productType = "com.apple.product-type.application"; + }; + EA463C8A1EF81E8F005AC8C7 /* 26_InverseKinematic */ = { + isa = PBXNativeTarget; + buildConfigurationList = EA463CAC1EF81E8F005AC8C7 /* Build configuration list for PBXNativeTarget "26_InverseKinematic" */; + buildPhases = ( + EA463C871EF81E8F005AC8C7 /* Sources */, + EA463C881EF81E8F005AC8C7 /* Frameworks */, + EA463C891EF81E8F005AC8C7 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + B2541D0021751B6B00F702BB /* PBXTargetDependency */, + B2C44070211E254B008F57D5 /* PBXTargetDependency */, + B2C44072211E254B008F57D5 /* PBXTargetDependency */, + ); + name = 26_InverseKinematic; + productName = 02_Texture; + productReference = EA463C8B1EF81E8F005AC8C7 /* 26_InverseKinematic.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + EA463C831EF81E8F005AC8C7 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1020; + ORGANIZATIONNAME = "Confetti-FX"; + TargetAttributes = { + C95132EC2010E68A002E584B = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Automatic; + }; + EA463C8A1EF81E8F005AC8C7 = { + CreatedOnToolsVersion = 8.3.3; + DevelopmentTeam = BT67ZY58A8; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = EA463C861EF81E8F005AC8C7 /* Build configuration list for PBXProject "26_InverseKinematic" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = EA463C821EF81E8F005AC8C7; + productRefGroup = EA463C8C1EF81E8F005AC8C7 /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = B23FA44C211E24F70059929A /* Products */; + ProjectRef = B23FA44B211E24F70059929A /* ozz.xcodeproj */; + }, + { + ProductGroup = B2541CF421751B4E00F702BB /* Products */; + ProjectRef = B2541CF321751B4E00F702BB /* The-Forge.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + EA463C8A1EF81E8F005AC8C7 /* 26_InverseKinematic */, + C95132EC2010E68A002E584B /* 26_InverseKinematic_iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 5CA80FDE21F0A28A00C99983 /* ozz_animation offline.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "ozz_animation offline.a"; + remoteRef = 5CA80FDD21F0A28A00C99983 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B23FA456211E24F70059929A /* json_d.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = json_d.a; + remoteRef = B23FA455211E24F70059929A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B23FA458211E24F70059929A /* ozz_animation.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = ozz_animation.a; + remoteRef = B23FA457211E24F70059929A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B23FA45C211E24F70059929A /* ozz_base.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = ozz_base.a; + remoteRef = B23FA45B211E24F70059929A /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B2541CFA21751B4E00F702BB /* libThe-Forge.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libThe-Forge.a"; + remoteRef = B2541CF921751B4E00F702BB /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + B2541CFC21751B4E00F702BB /* libThe-Forge_iOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = "libThe-Forge_iOS.a"; + remoteRef = B2541CFB21751B4E00F702BB /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + D0796AE7211ED7950028AFFD /* ozz_animation_IOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = ozz_animation_IOS.a; + remoteRef = D0796AE6211ED7950028AFFD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + D0796AE9211ED7950028AFFD /* ozz_base_IOS.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = ozz_base_IOS.a; + remoteRef = D0796AE8211ED7950028AFFD /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + C95132EB2010E68A002E584B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D0296BEC211EE433000C9281 /* LaunchScreen.storyboard in Resources */, + C95132FF2010E68A002E584B /* Assets.xcassets in Resources */, + B2B7406B21755F1200324803 /* circlepad.ktx in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EA463C891EF81E8F005AC8C7 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D28782F01F0A7F52004DC624 /* Assets.xcassets in Resources */, + D2E631E11F3472DF005BFBA7 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C95132E92010E68A002E584B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B2B7400F2175533E00324803 /* AppDelegate.m in Sources */, + B2B73FEA2175504F00324803 /* 26_InverseKinematic.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + EA463C871EF81E8F005AC8C7 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B2B73FE421754CB400324803 /* AppDelegate.m in Sources */, + B2B73FC721754A3B00324803 /* 26_InverseKinematic.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + B2541D0021751B6B00F702BB /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "The-Forge"; + targetProxy = B2541CFF21751B6B00F702BB /* PBXContainerItemProxy */; + }; + B2541D0221751B6F00F702BB /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = "The-Forge_iOS"; + targetProxy = B2541D0121751B6F00F702BB /* PBXContainerItemProxy */; + }; + B2C44070211E254B008F57D5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = ozz_animation; + targetProxy = B2C4406F211E254B008F57D5 /* PBXContainerItemProxy */; + }; + B2C44072211E254B008F57D5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = ozz_base; + targetProxy = B2C44071211E254B008F57D5 /* PBXContainerItemProxy */; + }; + D0796AE0211ED7950028AFFD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = ozz_animation_IOS; + targetProxy = D0796ADF211ED7950028AFFD /* PBXContainerItemProxy */; + }; + D0796AE2211ED7950028AFFD /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = ozz_base_IOS; + targetProxy = D0796AE1211ED7950028AFFD /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + D0296BEA211EE433000C9281 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + D0296BEB211EE433000C9281 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; + D2E631DF1F3472DF005BFBA7 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + D2E631E01F3472DF005BFBA7 /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + C95133062010E68A002E584B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_COMMA = NO; + CLANG_WARN_UNGUARDED_AVAILABILITY = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COMPRESS_PNG_FILES = NO; + CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../Bin/$(CONFIGURATION)/"; + DEVELOPMENT_TEAM = BT67ZY58A8; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_PREPROCESSOR_DEFINITIONS = ( + METAL, + _DEBUG, + TARGET_IOS, + USE_MEMORY_TRACKING, + ); + INFOPLIST_FILE = "$(SRCROOT)/$(TARGET_NAME)/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.26-InverseKinematic-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + STRIP_PNG_TEXT = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + USE_HEADERMAP = NO; + }; + name = Debug; + }; + C95133072010E68A002E584B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_COMMA = NO; + CLANG_WARN_UNGUARDED_AVAILABILITY = NO; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + COMPRESS_PNG_FILES = NO; + CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../Bin/$(CONFIGURATION)/"; + DEVELOPMENT_TEAM = BT67ZY58A8; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_PREPROCESSOR_DEFINITIONS = ( + METAL, + _DEBUG, + TARGET_IOS, + ); + INFOPLIST_FILE = "$(SRCROOT)/$(TARGET_NAME)/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.26-InverseKinematic-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = iphoneos; + STRIP_PNG_TEXT = NO; + TARGETED_DEVICE_FAMILY = "1,2"; + USE_HEADERMAP = NO; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + EA463CAA1EF81E8F005AC8C7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = NO; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + "HEADER_SEARCH_PATHS[arch=*]" = ""; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + EA463CAB1EF81E8F005AC8C7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = NO; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + EA463CAD1EF81E8F005AC8C7 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_COMMA = NO; + COMBINE_HIDPI_IMAGES = YES; + CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../Bin/$(CONFIGURATION)/"; + DEVELOPMENT_TEAM = BT67ZY58A8; + GCC_PREPROCESSOR_DEFINITIONS = ( + METAL, + _DEBUG, + USE_MEMORY_TRACKING, + ); + INFOPLIST_FILE = "$(SRCROOT)/26_InverseKinematic/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.26-InverseKinematic"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Debug; + }; + EA463CAE1EF81E8F005AC8C7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_WARN_COMMA = NO; + COMBINE_HIDPI_IMAGES = YES; + CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../Bin/$(CONFIGURATION)/"; + DEVELOPMENT_TEAM = BT67ZY58A8; + GCC_PREPROCESSOR_DEFINITIONS = METAL; + INFOPLIST_FILE = "$(SRCROOT)/26_InverseKinematic/Info.plist"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + MACOSX_DEPLOYMENT_TARGET = 10.14; + PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.26-InverseKinematic"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = macosx; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C95133082010E68A002E584B /* Build configuration list for PBXNativeTarget "26_InverseKinematic_iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C95133062010E68A002E584B /* Debug */, + C95133072010E68A002E584B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EA463C861EF81E8F005AC8C7 /* Build configuration list for PBXProject "26_InverseKinematic" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EA463CAA1EF81E8F005AC8C7 /* Debug */, + EA463CAB1EF81E8F005AC8C7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + EA463CAC1EF81E8F005AC8C7 /* Build configuration list for PBXNativeTarget "26_InverseKinematic" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + EA463CAD1EF81E8F005AC8C7 /* Debug */, + EA463CAE1EF81E8F005AC8C7 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = EA463C831EF81E8F005AC8C7 /* Project object */; +} diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..67da7dacc6 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/xcshareddata/xcschemes/26_InverseKinematic.xcscheme b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/xcshareddata/xcschemes/26_InverseKinematic.xcscheme new file mode 100644 index 0000000000..2a3718b2d0 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/xcshareddata/xcschemes/26_InverseKinematic.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/xcshareddata/xcschemes/26_InverseKinematic_iOS.xcscheme b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/xcshareddata/xcschemes/26_InverseKinematic_iOS.xcscheme new file mode 100644 index 0000000000..34aa113397 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic.xcodeproj/xcshareddata/xcschemes/26_InverseKinematic_iOS.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/ColorMap.imageset/ColorMap.png b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/ColorMap.imageset/ColorMap.png similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/ColorMap.imageset/ColorMap.png rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/ColorMap.imageset/ColorMap.png diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/ColorMap.imageset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/ColorMap.imageset/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/ColorMap.imageset/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/ColorMap.imageset/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Assets.xcassets/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Assets.xcassets/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Base.lproj/MainMenu.xib b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Base.lproj/MainMenu.xib new file mode 100644 index 0000000000..8733f80f3f --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Base.lproj/MainMenu.xib @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Info.plist b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Info.plist similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Info.plist rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic/Info.plist diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/ColorMap.textureset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/ColorMap.textureset/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/ColorMap.textureset/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/ColorMap.textureset/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/Contents.json similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Assets.xcassets/Contents.json rename to Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Assets.xcassets/Contents.json diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Base.lproj/LaunchScreen.storyboard b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..d15952f62a --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Info.plist b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Info.plist new file mode 100644 index 0000000000..2e829336be --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/26_InverseKinematic/26_InverseKinematic_iOS/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + 26_InverseKinematic_iOS + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + armv7 + metal + + UIRequiresFullScreen + + UIStatusBarHidden + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.pbxproj b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.pbxproj similarity index 96% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.pbxproj rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.pbxproj index ffe7b4918d..c4d6951355 100644 --- a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.pbxproj +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.pbxproj @@ -18,8 +18,8 @@ 5CA80FB321F0A22F00C99983 /* imgui.vert.metal in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 5CA80EF421F0A07800C99983 /* imgui.vert.metal */; }; 5CA80FB421F0A22F00C99983 /* textured_mesh.frag.metal in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 5CA80EF221F0A07700C99983 /* textured_mesh.frag.metal */; }; 5CA80FB521F0A22F00C99983 /* textured_mesh.vert.metal in Copy Shaders */ = {isa = PBXBuildFile; fileRef = 5CA80EF121F0A07700C99983 /* textured_mesh.vert.metal */; }; - 5CB04F5D21353D1E000BDFE0 /* 26_Audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CB04F5C21353D1E000BDFE0 /* 26_Audio.cpp */; }; - 5CB04F5E21353D1E000BDFE0 /* 26_Audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CB04F5C21353D1E000BDFE0 /* 26_Audio.cpp */; }; + 5CB04F5D21353D1E000BDFE0 /* 27_Audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CB04F5C21353D1E000BDFE0 /* 27_Audio.cpp */; }; + 5CB04F5E21353D1E000BDFE0 /* 27_Audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CB04F5C21353D1E000BDFE0 /* 27_Audio.cpp */; }; 6500B87122C1592800A0CA66 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6500B87022C1592700A0CA66 /* AudioToolbox.framework */; }; 6500B87A22C1599A00A0CA66 /* Audio in Copy Audio Assets */ = {isa = PBXBuildFile; fileRef = 6500B87822C1598D00A0CA66 /* Audio */; }; 650CCC6D2223CD07003533D9 /* MetalPerformanceShaders.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 650CCC6C2223CD07003533D9 /* MetalPerformanceShaders.framework */; }; @@ -222,7 +222,7 @@ 5CA80EFD21F0A07E00C99983 /* fontstash3D.vert.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = fontstash3D.vert.metal; path = ../../../../Middleware_3/Text/Shaders/Metal/fontstash3D.vert.metal; sourceTree = ""; }; 5CA80EFE21F0A07E00C99983 /* fontstash2D.vert.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = fontstash2D.vert.metal; path = ../../../../Middleware_3/Text/Shaders/Metal/fontstash2D.vert.metal; sourceTree = ""; }; 5CA80EFF21F0A07E00C99983 /* fontstash.frag.metal */ = {isa = PBXFileReference; explicitFileType = text; fileEncoding = 4; name = fontstash.frag.metal; path = ../../../../Middleware_3/Text/Shaders/Metal/fontstash.frag.metal; sourceTree = ""; }; - 5CB04F5C21353D1E000BDFE0 /* 26_Audio.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = 26_Audio.cpp; path = ../../../src/26_Audio/26_Audio.cpp; sourceTree = ""; }; + 5CB04F5C21353D1E000BDFE0 /* 27_Audio.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; name = 27_Audio.cpp; path = ../../../src/27_Audio/27_Audio.cpp; sourceTree = ""; }; 6500B87022C1592700A0CA66 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.2.sdk/System/Library/Frameworks/AudioToolbox.framework; sourceTree = DEVELOPER_DIR; }; 6500B87822C1598D00A0CA66 /* Audio */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Audio; path = ../../UnitTestResources/Audio; sourceTree = ""; }; 650CCC6C2223CD07003533D9 /* MetalPerformanceShaders.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalPerformanceShaders.framework; path = System/Library/Frameworks/MetalPerformanceShaders.framework; sourceTree = SDKROOT; }; @@ -293,14 +293,14 @@ B22D906820E2EDCE0036B88E /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; }; B27D879920E2E88B00081DB0 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; }; B2D1CEB320EAECDB001BB8C4 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; - C95132ED2010E68A002E584B /* 26_Audio_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 26_Audio_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C95132ED2010E68A002E584B /* 27_Audio_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 27_Audio_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; C95132FE2010E68A002E584B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; C95133012010E68A002E584B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; C95133032010E68A002E584B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D28782EF1F0A7F52004DC624 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ../02_Compute/02_Compute/Assets.xcassets; sourceTree = SOURCE_ROOT; }; D2E631E01F3472DF005BFBA7 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; - EA463C8B1EF81E8F005AC8C7 /* 26_Audio.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 26_Audio.app; sourceTree = BUILT_PRODUCTS_DIR; }; - EADF9D661EFD160E00B2008B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../02_Compute/02_Compute/Info.plist; sourceTree = SOURCE_ROOT; }; + EA463C8B1EF81E8F005AC8C7 /* 27_Audio.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 27_Audio.app; sourceTree = BUILT_PRODUCTS_DIR; }; + EADF9D661EFD160E00B2008B /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = 27_Audio/Info.plist; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -577,7 +577,7 @@ path = coreaudio; sourceTree = ""; }; - C95132EE2010E68A002E584B /* 26_Audio_iOS */ = { + C95132EE2010E68A002E584B /* 27_Audio_iOS */ = { isa = PBXGroup; children = ( 5C512C412141555B00E7A798 /* AppDelegate.h */, @@ -586,7 +586,7 @@ C95133002010E68A002E584B /* LaunchScreen.storyboard */, C95133032010E68A002E584B /* Info.plist */, ); - path = 26_Audio_iOS; + path = 27_Audio_iOS; sourceTree = ""; }; EA463C821EF81E8F005AC8C7 = { @@ -597,8 +597,8 @@ 5CA80E1A21F09F9C00C99983 /* CommonShaders */, 5C512C442141556900E7A798 /* The-Forge.xcodeproj */, 28A5AB88201F3A44000E571F /* Fonts */, - EA463C941EF81E8F005AC8C7 /* 26_Audio */, - C95132EE2010E68A002E584B /* 26_Audio_iOS */, + EA463C941EF81E8F005AC8C7 /* 27_Audio */, + C95132EE2010E68A002E584B /* 27_Audio_iOS */, EA463C8C1EF81E8F005AC8C7 /* Products */, 28A5ABEA201F482F000E571F /* Frameworks */, ); @@ -607,31 +607,31 @@ EA463C8C1EF81E8F005AC8C7 /* Products */ = { isa = PBXGroup; children = ( - EA463C8B1EF81E8F005AC8C7 /* 26_Audio.app */, - C95132ED2010E68A002E584B /* 26_Audio_iOS.app */, + EA463C8B1EF81E8F005AC8C7 /* 27_Audio.app */, + C95132ED2010E68A002E584B /* 27_Audio_iOS.app */, ); name = Products; sourceTree = ""; }; - EA463C941EF81E8F005AC8C7 /* 26_Audio */ = { + EA463C941EF81E8F005AC8C7 /* 27_Audio */ = { isa = PBXGroup; children = ( 5C512C3F2141555200E7A798 /* AppDelegate.h */, 5C512C3E2141555200E7A798 /* AppDelegate.m */, - 5CB04F5C21353D1E000BDFE0 /* 26_Audio.cpp */, + 5CB04F5C21353D1E000BDFE0 /* 27_Audio.cpp */, D2E631DF1F3472DF005BFBA7 /* MainMenu.xib */, D28782EF1F0A7F52004DC624 /* Assets.xcassets */, EADF9D661EFD160E00B2008B /* Info.plist */, ); - path = 26_Audio; + path = 27_Audio; sourceTree = SOURCE_ROOT; }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - C95132EC2010E68A002E584B /* 26_Audio_iOS */ = { + C95132EC2010E68A002E584B /* 27_Audio_iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = C95133082010E68A002E584B /* Build configuration list for PBXNativeTarget "26_Audio_iOS" */; + buildConfigurationList = C95133082010E68A002E584B /* Build configuration list for PBXNativeTarget "27_Audio_iOS" */; buildPhases = ( C95132E92010E68A002E584B /* Sources */, C95132EA2010E68A002E584B /* Frameworks */, @@ -645,14 +645,14 @@ dependencies = ( 5C512C502141557C00E7A798 /* PBXTargetDependency */, ); - name = 26_Audio_iOS; + name = 27_Audio_iOS; productName = 01_Transformations_iOS; - productReference = C95132ED2010E68A002E584B /* 26_Audio_iOS.app */; + productReference = C95132ED2010E68A002E584B /* 27_Audio_iOS.app */; productType = "com.apple.product-type.application"; }; - EA463C8A1EF81E8F005AC8C7 /* 26_Audio */ = { + EA463C8A1EF81E8F005AC8C7 /* 27_Audio */ = { isa = PBXNativeTarget; - buildConfigurationList = EA463CAC1EF81E8F005AC8C7 /* Build configuration list for PBXNativeTarget "26_Audio" */; + buildConfigurationList = EA463CAC1EF81E8F005AC8C7 /* Build configuration list for PBXNativeTarget "27_Audio" */; buildPhases = ( EA463C871EF81E8F005AC8C7 /* Sources */, EA463C881EF81E8F005AC8C7 /* Frameworks */, @@ -663,9 +663,9 @@ dependencies = ( 5C512C4E2141557700E7A798 /* PBXTargetDependency */, ); - name = 26_Audio; + name = 27_Audio; productName = 02_Texture; - productReference = EA463C8B1EF81E8F005AC8C7 /* 26_Audio.app */; + productReference = EA463C8B1EF81E8F005AC8C7 /* 27_Audio.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -689,7 +689,7 @@ }; }; }; - buildConfigurationList = EA463C861EF81E8F005AC8C7 /* Build configuration list for PBXProject "26_Audio" */; + buildConfigurationList = EA463C861EF81E8F005AC8C7 /* Build configuration list for PBXProject "27_Audio" */; compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; @@ -708,8 +708,8 @@ ); projectRoot = ""; targets = ( - EA463C8A1EF81E8F005AC8C7 /* 26_Audio */, - C95132EC2010E68A002E584B /* 26_Audio_iOS */, + EA463C8A1EF81E8F005AC8C7 /* 27_Audio */, + C95132EC2010E68A002E584B /* 27_Audio_iOS */, ); }; /* End PBXProject section */ @@ -783,7 +783,7 @@ 650FCAE122C156A600EF81BC /* soloud_core_getters.cpp in Sources */, 650FCAE922C156A600EF81BC /* soloud_echofilter.cpp in Sources */, 650FCB1B22C156A600EF81BC /* soloud_vizsn.cpp in Sources */, - 5CB04F5E21353D1E000BDFE0 /* 26_Audio.cpp in Sources */, + 5CB04F5E21353D1E000BDFE0 /* 27_Audio.cpp in Sources */, 650FCACD22C156A600EF81BC /* soloud.cpp in Sources */, 650FCB0B22C156A600EF81BC /* klatt.cpp in Sources */, 650FCAD522C156A600EF81BC /* soloud_core_voiceops.cpp in Sources */, @@ -839,7 +839,7 @@ 650FCAE022C156A600EF81BC /* soloud_core_getters.cpp in Sources */, 650FCAE822C156A600EF81BC /* soloud_echofilter.cpp in Sources */, 650FCB1A22C156A600EF81BC /* soloud_vizsn.cpp in Sources */, - 5CB04F5D21353D1E000BDFE0 /* 26_Audio.cpp in Sources */, + 5CB04F5D21353D1E000BDFE0 /* 27_Audio.cpp in Sources */, 650FCACC22C156A600EF81BC /* soloud.cpp in Sources */, 650FCB0A22C156A600EF81BC /* klatt.cpp in Sources */, 650FCAD422C156A600EF81BC /* soloud_core_voiceops.cpp in Sources */, @@ -928,14 +928,14 @@ "values>", "$(PROJECT_DIR)/../../../../Common_3/ThirdParty/OpenSource/soloud20181119/include", ); - INFOPLIST_FILE = 26_Audio_iOS/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/27_Audio_iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - PRODUCT_BUNDLE_IDENTIFIER = "Conffeti.-26-Audio-iOS"; + PRODUCT_BUNDLE_IDENTIFIER = "Conffeti.-27-Audio-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; STRIP_PNG_TEXT = NO; @@ -969,14 +969,14 @@ "values>", "$(PROJECT_DIR)/../../../../Common_3/ThirdParty/OpenSource/soloud20181119/include", ); - INFOPLIST_FILE = 26_Audio_iOS/Info.plist; + INFOPLIST_FILE = "$(SRCROOT)/27_Audio_iOS/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - PRODUCT_BUNDLE_IDENTIFIER = "Conffeti.-26-Audio-iOS"; + PRODUCT_BUNDLE_IDENTIFIER = "Conffeti.-27-Audio-iOS"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; STRIP_PNG_TEXT = NO; @@ -1119,13 +1119,13 @@ ../, "$(PROJECT_DIR)/../../../../Common_3/ThirdParty/OpenSource/soloud20181119/include", ); - INFOPLIST_FILE = "$(SRCROOT)/../02_Compute/02_Compute/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/27_Audio/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.26-Audio"; + PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.27-Audio"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SYSTEM_FRAMEWORK_SEARCH_PATHS = ""; @@ -1142,22 +1142,20 @@ COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/../Bin/$(CONFIGURATION)/"; DEVELOPMENT_TEAM = BT67ZY58A8; - GCC_PREPROCESSOR_DEFINITIONS = ( - METAL, - ); + GCC_PREPROCESSOR_DEFINITIONS = METAL; HEADER_SEARCH_PATHS = ( ../../Common_3, ../../, ../, "$(PROJECT_DIR)/../../../../Common_3/ThirdParty/OpenSource/soloud20181119/include", ); - INFOPLIST_FILE = "$(SRCROOT)/../02_Compute/02_Compute/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/27_Audio/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.14; - PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.26-Audio"; + PRODUCT_BUNDLE_IDENTIFIER = "com.confetti.Unit-Tests.27-Audio"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SYSTEM_FRAMEWORK_SEARCH_PATHS = ""; @@ -1168,7 +1166,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - C95133082010E68A002E584B /* Build configuration list for PBXNativeTarget "26_Audio_iOS" */ = { + C95133082010E68A002E584B /* Build configuration list for PBXNativeTarget "27_Audio_iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( C95133062010E68A002E584B /* Debug */, @@ -1177,7 +1175,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - EA463C861EF81E8F005AC8C7 /* Build configuration list for PBXProject "26_Audio" */ = { + EA463C861EF81E8F005AC8C7 /* Build configuration list for PBXProject "27_Audio" */ = { isa = XCConfigurationList; buildConfigurations = ( EA463CAA1EF81E8F005AC8C7 /* Debug */, @@ -1186,7 +1184,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - EA463CAC1EF81E8F005AC8C7 /* Build configuration list for PBXNativeTarget "26_Audio" */ = { + EA463CAC1EF81E8F005AC8C7 /* Build configuration list for PBXNativeTarget "27_Audio" */ = { isa = XCConfigurationList; buildConfigurations = ( EA463CAD1EF81E8F005AC8C7 /* Debug */, diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000000..18d981003d --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/xcshareddata/xcschemes/26_Audio.xcscheme b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/xcshareddata/xcschemes/27_Audio.xcscheme similarity index 82% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/xcshareddata/xcschemes/26_Audio.xcscheme rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/xcshareddata/xcschemes/27_Audio.xcscheme index e8e6fd4a58..d9484edd2c 100644 --- a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/xcshareddata/xcschemes/26_Audio.xcscheme +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/xcshareddata/xcschemes/27_Audio.xcscheme @@ -15,9 +15,9 @@ + BuildableName = "27_Audio.app" + BlueprintName = "27_Audio" + ReferencedContainer = "container:27_Audio.xcodeproj"> @@ -33,9 +33,9 @@ + BuildableName = "27_Audio.app" + BlueprintName = "27_Audio" + ReferencedContainer = "container:27_Audio.xcodeproj"> @@ -56,9 +56,9 @@ + BuildableName = "27_Audio.app" + BlueprintName = "27_Audio" + ReferencedContainer = "container:27_Audio.xcodeproj"> @@ -75,9 +75,9 @@ + BuildableName = "27_Audio.app" + BlueprintName = "27_Audio" + ReferencedContainer = "container:27_Audio.xcodeproj"> diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/xcshareddata/xcschemes/26_Audio_iOS.xcscheme b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/xcshareddata/xcschemes/27_Audio_iOS.xcscheme similarity index 81% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/xcshareddata/xcschemes/26_Audio_iOS.xcscheme rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/xcshareddata/xcschemes/27_Audio_iOS.xcscheme index 1c255dea52..417fbea820 100644 --- a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio.xcodeproj/xcshareddata/xcschemes/26_Audio_iOS.xcscheme +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio.xcodeproj/xcshareddata/xcschemes/27_Audio_iOS.xcscheme @@ -15,9 +15,9 @@ + BuildableName = "27_Audio_iOS.app" + BlueprintName = "27_Audio_iOS" + ReferencedContainer = "container:27_Audio.xcodeproj"> @@ -33,9 +33,9 @@ + BuildableName = "27_Audio_iOS.app" + BlueprintName = "27_Audio_iOS" + ReferencedContainer = "container:27_Audio.xcodeproj"> @@ -56,9 +56,9 @@ + BuildableName = "27_Audio_iOS.app" + BlueprintName = "27_Audio_iOS" + ReferencedContainer = "container:27_Audio.xcodeproj"> @@ -75,9 +75,9 @@ + BuildableName = "27_Audio_iOS.app" + BlueprintName = "27_Audio_iOS" + ReferencedContainer = "container:27_Audio.xcodeproj"> diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..2db2b1c7c6 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/ColorMap.imageset/ColorMap.png b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/ColorMap.imageset/ColorMap.png new file mode 100644 index 0000000000..06476683fe Binary files /dev/null and b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/ColorMap.imageset/ColorMap.png differ diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/ColorMap.imageset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/ColorMap.imageset/Contents.json new file mode 100644 index 0000000000..9756d56830 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/ColorMap.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "ColorMap.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..da4a164c91 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Base.lproj/MainMenu.xib b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Base.lproj/MainMenu.xib similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio/Base.lproj/MainMenu.xib rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Base.lproj/MainMenu.xib diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Info.plist b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Info.plist new file mode 100644 index 0000000000..a801f531f2 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2017 Confetti. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..a5c370a6c6 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,221 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + }, + { + "size" : "24x24", + "idiom" : "watch", + "scale" : "2x", + "role" : "notificationCenter", + "subtype" : "38mm" + }, + { + "size" : "27.5x27.5", + "idiom" : "watch", + "scale" : "2x", + "role" : "notificationCenter", + "subtype" : "42mm" + }, + { + "size" : "29x29", + "idiom" : "watch", + "role" : "companionSettings", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "watch", + "role" : "companionSettings", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "38mm" + }, + { + "size" : "44x44", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "40mm" + }, + { + "size" : "50x50", + "idiom" : "watch", + "scale" : "2x", + "role" : "appLauncher", + "subtype" : "44mm" + }, + { + "size" : "86x86", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "38mm" + }, + { + "size" : "98x98", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "42mm" + }, + { + "size" : "108x108", + "idiom" : "watch", + "scale" : "2x", + "role" : "quickLook", + "subtype" : "44mm" + }, + { + "idiom" : "watch-marketing", + "size" : "1024x1024", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "16x16", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "32x32", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "128x128", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "256x256", + "scale" : "2x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "1x" + }, + { + "idiom" : "mac", + "size" : "512x512", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Contents.json new file mode 100644 index 0000000000..702494cfd9 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Contents.json @@ -0,0 +1,17 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "properties" : { + "origin" : "bottom-left", + "interpretation" : "non-premultiplied-colors" + }, + "textures" : [ + { + "idiom" : "universal", + "filename" : "Universal.mipmapset" + } + ] +} + diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png new file mode 100644 index 0000000000..ddf9519d46 Binary files /dev/null and b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png differ diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json new file mode 100644 index 0000000000..83ae34babc --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json @@ -0,0 +1,12 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "levels" : [ + { + "filename" : "ColorMap.png", + "mipmap-level" : "base" + } + ] +} diff --git a/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/Contents.json b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/Contents.json new file mode 100644 index 0000000000..da4a164c91 --- /dev/null +++ b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Base.lproj/LaunchScreen.storyboard b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Base.lproj/LaunchScreen.storyboard similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Base.lproj/LaunchScreen.storyboard rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Base.lproj/LaunchScreen.storyboard diff --git a/Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Info.plist b/Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Info.plist similarity index 100% rename from Examples_3/Unit_Tests/macOS Xcode/26_Audio/26_Audio_iOS/Info.plist rename to Examples_3/Unit_Tests/macOS Xcode/27_Audio/27_Audio_iOS/Info.plist diff --git a/Examples_3/Unit_Tests/macOS Xcode/The-Forge/The-Forge.xcodeproj/project.pbxproj b/Examples_3/Unit_Tests/macOS Xcode/The-Forge/The-Forge.xcodeproj/project.pbxproj index 172201ec92..9b29705527 100644 --- a/Examples_3/Unit_Tests/macOS Xcode/The-Forge/The-Forge.xcodeproj/project.pbxproj +++ b/Examples_3/Unit_Tests/macOS Xcode/The-Forge/The-Forge.xcodeproj/project.pbxproj @@ -221,7 +221,7 @@ 5C172F47214148830074EE71 /* GpuProfiler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GpuProfiler.h; sourceTree = ""; }; 5C172F48214148830074EE71 /* IShaderReflection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IShaderReflection.h; sourceTree = ""; }; 5C172F49214148830074EE71 /* CommonShaderReflection.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = CommonShaderReflection.cpp; sourceTree = ""; }; - 5C172F4A214148840074EE71 /* MetalRenderer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MetalRenderer.mm; path = Metal/MetalRenderer.mm; sourceTree = ""; }; + 5C172F4A214148840074EE71 /* MetalRenderer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MetalRenderer.mm; path = Metal/MetalRenderer.mm; sourceTree = ""; usesTabs = 1; }; 5C172F4B214148840074EE71 /* MetalShaderReflection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MetalShaderReflection.mm; path = Metal/MetalShaderReflection.mm; sourceTree = ""; }; 5C172F4C214148840074EE71 /* MetalMemoryAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MetalMemoryAllocator.h; path = Metal/MetalMemoryAllocator.h; sourceTree = ""; }; 5C172F4D214148840074EE71 /* ResourceLoader.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = ResourceLoader.cpp; sourceTree = ""; }; diff --git a/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/contents.xcworkspacedata b/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/contents.xcworkspacedata index 7a4aa35f46..42be2a2be0 100644 --- a/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/contents.xcworkspacedata +++ b/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/contents.xcworkspacedata @@ -28,6 +28,9 @@ + + + location = "group:27_Audio/27_Audio.xcodeproj"> diff --git a/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/xcshareddata/xcschemes/BuildAll.xcscheme b/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/xcshareddata/xcschemes/BuildAll.xcscheme index c607457302..887d1a3d9c 100644 --- a/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/xcshareddata/xcschemes/BuildAll.xcscheme +++ b/Examples_3/Unit_Tests/macOS Xcode/Unit_Tests.xcworkspace/xcshareddata/xcschemes/BuildAll.xcscheme @@ -645,9 +645,9 @@ + BuildableName = "27_Audio.app" + BlueprintName = "27_Audio" + ReferencedContainer = "container:27_Audio/27_Audio.xcodeproj"> + BuildableName = "27_Audio_iOS.app" + BlueprintName = "27_Audio_iOS" + ReferencedContainer = "container:27_Audio/27_Audio.xcodeproj"> + + + + + + + + - - - - + + - - pTexture, RESOURCE_STATE_COMMON }, + }; + + cmdResourceBarrier(cmd, 0, NULL, 1, rtBarriers); + + cmdBindRenderTargets(cmd, 0, NULL, NULL, NULL, NULL, NULL, -1, -1); + BufferBarrier uavBarriers[] = { { pBladeNumBuffer, RESOURCE_STATE_UNORDERED_ACCESS }, { pCulledBladeStorageBuffer, RESOURCE_STATE_UNORDERED_ACCESS }, @@ -935,6 +947,11 @@ class Tessellation: public IApp // Draw UI cmd = ppUICmds[gFrameIndex]; beginCmd(cmd); + + rtBarriers[0] = { pRenderTarget->pTexture, RESOURCE_STATE_RENDER_TARGET }, + + cmdResourceBarrier(cmd, 0, NULL, 1, rtBarriers); + cmdBeginDebugMarker(cmd, 0, 1, 0, "Draw UI"); cmdBindRenderTargets(cmd, 1, &pRenderTarget, NULL, NULL, NULL, NULL, -1, -1); cmdSetViewport(cmd, 0.0f, 0.0f, (float)pRenderTarget->mDesc.mWidth, (float)pRenderTarget->mDesc.mHeight, 0.0f, 1.0f); @@ -1003,6 +1020,7 @@ class Tessellation: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/08_GltfViewer/08_GltfViewer.cpp b/Examples_3/Unit_Tests/src/08_GltfViewer/08_GltfViewer.cpp index c4bc64c2ba..5dfeb3a598 100644 --- a/Examples_3/Unit_Tests/src/08_GltfViewer/08_GltfViewer.cpp +++ b/Examples_3/Unit_Tests/src/08_GltfViewer/08_GltfViewer.cpp @@ -1731,7 +1731,7 @@ class MeshOptimization : public IApp params[0].ppBuffers = &pUniformBuffer[i]; params[1].pName = "ShadowUniformBuffer"; params[1].ppBuffers = &pShadowUniformBuffer[i]; - updateDescriptorSet(pRenderer, i, pDescriptorSetDemo[1], 1, params); + updateDescriptorSet(pRenderer, i, pDescriptorSetDemo[1], 2, params); } //bind textures @@ -2455,22 +2455,14 @@ class MeshOptimization : public IApp cmdDrawIndexed(cmd, 6, 0, 0); - cmdBindRenderTargets(cmd, 0, NULL, 0, NULL, NULL, NULL, -1, -1); - cmdEndGpuTimestampQuery(cmd, pGpuProfiler); } //// draw scene { - LoadActionsDesc loadActions = {}; - loadActions.mLoadActionsColor[0] = LOAD_ACTION_LOAD; - loadActions.mLoadActionDepth = LOAD_ACTION_LOAD; - loadActions.mLoadActionStencil = LOAD_ACTION_LOAD; - cmdBeginGpuTimestampQuery(cmd, pGpuProfiler, "Draw Scene", true); - cmdBindRenderTargets(cmd, 1, &pRenderTarget, pDepthBuffer, &loadActions, NULL, NULL, -1, -1); cmdSetViewport(cmd, 0.0f, 0.0f, (float)pRenderTarget->mDesc.mWidth, (float)pRenderTarget->mDesc.mHeight, 0.0f, 1.0f); cmdSetScissor(cmd, 0, 0, pRenderTarget->mDesc.mWidth, pRenderTarget->mDesc.mHeight); @@ -2721,6 +2713,7 @@ class MeshOptimization : public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); /************************************************************************/ diff --git a/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/FXAA.frag.metal b/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/FXAA.frag.metal index cde61282b9..f2bac927fc 100644 --- a/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/FXAA.frag.metal +++ b/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/FXAA.frag.metal @@ -177,11 +177,13 @@ struct Fragment_Shader float4 main(PSIn input) { float3 result = float3((float)0.0, (float)0.0, (float)0.0); +#ifndef TARGET_IOS if (FXAARootConstant.Use) { (result = FXAA((input).TexCoord, int2((int2)((input).TexCoord * FXAARootConstant.ScreenSize)))); } else +#endif { (result = (float3)(sceneTexture.sample(clampMiplessLinearSampler, (input).TexCoord).rgb)); } diff --git a/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/basic.frag.metal b/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/basic.frag.metal index 595efc7941..f841ce4820 100644 --- a/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/basic.frag.metal +++ b/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/basic.frag.metal @@ -217,7 +217,7 @@ uint alphaMode, uint unlit) return result; } -float CalcESMShadowFactor(float4x4 LightViewProj, float3 worldPos, texture2d shadowTexture, sampler shadowSampler) +float CalcESMShadowFactor(float4x4 LightViewProj, float3 worldPos, texture2d shadowTexture, sampler shadowSampler) { float4 posLS = LightViewProj * float4(worldPos.xyz, 1.0); posLS /= posLS.w; @@ -250,7 +250,7 @@ float random(float3 seed, float3 freq) return fract(sin(dt) * 2105.2354); } -float CalcPCFShadowFactor(float4x4 LightViewProj, float3 worldPos, texture2d shadowTexture, sampler shadowSampler) +float CalcPCFShadowFactor(float4x4 LightViewProj, float3 worldPos, depth2d shadowTexture, sampler shadowSampler) { float4 posLS = LightViewProj * float4(worldPos.xyz, 1.0); posLS /= posLS.w; @@ -275,14 +275,14 @@ float CalcPCFShadowFactor(float4x4 LightViewProj, float3 worldPos, texture2d posLS.z ? 0.0f : 1.0f); } shadowFactor *= NUM_SHADOW_SAMPLES_INV; return shadowFactor; } -float ClaculateShadow(float4x4 LightViewProj, float3 worldPos, texture2d shadowTexture, sampler shadowSampler) +float ClaculateShadow(float4x4 LightViewProj, float3 worldPos, texture2d shadowTexture, sampler shadowSampler) { float4 NDC = LightViewProj * float4(worldPos, 1.0); NDC /= NDC.w; @@ -345,7 +345,7 @@ struct PSOut struct Scene { - texture2d ShadowTexture [[id(0)]]; + depth2d ShadowTexture [[id(0)]]; sampler clampMiplessLinearSampler [[id(1)]]; }; diff --git a/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/floor.frag.metal b/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/floor.frag.metal index 241dadeba3..9aba2078cf 100644 --- a/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/floor.frag.metal +++ b/Examples_3/Unit_Tests/src/08_GltfViewer/Shaders/Metal/floor.frag.metal @@ -24,10 +24,11 @@ #include using namespace metal; +constant const float NUM_SHADOW_SAMPLES_INV = 0.03125f; +constant const float shadowSamples[(32 * 2)] = { (-0.17466460), (-0.79131840), (-0.129792), (-0.44771160), 0.08863912, (-0.8981690), (-0.58914988), (-0.678163), 0.17484090, (-0.5252063), 0.6483325, (-0.752117), 0.45293192, (-0.384986), 0.09757467, (-0.1166954), 0.3857658, (-0.9096935), 0.56130584, (-0.1283066), 0.768011, (-0.4906538), 0.8499438, (-0.220937), 0.6946555, 0.16058660, 0.9614297, 0.0597522, 0.7986544, 0.53259124, 0.45139648, 0.5592551, 0.2847693, 0.2293397, (-0.2118996), (-0.1609127), (-0.4357893), (-0.3808875), (-0.4662672), (-0.05288446), (-0.139129), 0.23940650, 0.1781853, 0.5254948, 0.4287854, 0.899425, 0.12893490, 0.8724155, (-0.6924323), (-0.2203967), (-0.48997), 0.2795907, (-0.26117242), 0.7359962, (-0.7704172), 0.42331340, (-0.8501040), 0.12639350, (-0.83452672), (-0.499136), (-0.5380967), 0.6264234, (-0.9769312), (-0.15505689) }; + struct Fragment_Shader { - const float NUM_SHADOW_SAMPLES_INV = (const float)(0.03125); - const float shadowSamples[(32 * 2)] = { (-0.17466460), (-0.79131840), (-0.129792), (-0.44771160), 0.08863912, (-0.8981690), (-0.58914988), (-0.678163), 0.17484090, (-0.5252063), 0.6483325, (-0.752117), 0.45293192, (-0.384986), 0.09757467, (-0.1166954), 0.3857658, (-0.9096935), 0.56130584, (-0.1283066), 0.768011, (-0.4906538), 0.8499438, (-0.220937), 0.6946555, 0.16058660, 0.9614297, 0.0597522, 0.7986544, 0.53259124, 0.45139648, 0.5592551, 0.2847693, 0.2293397, (-0.2118996), (-0.1609127), (-0.4357893), (-0.3808875), (-0.4662672), (-0.05288446), (-0.139129), 0.23940650, 0.1781853, 0.5254948, 0.4287854, 0.899425, 0.12893490, 0.8724155, (-0.6924323), (-0.2203967), (-0.48997), 0.2795907, (-0.26117242), 0.7359962, (-0.7704172), 0.42331340, (-0.8501040), 0.12639350, (-0.83452672), (-0.499136), (-0.5380967), 0.6264234, (-0.9769312), (-0.15505689) }; struct Uniforms_ShadowUniformBuffer { float4x4 LightViewProj; @@ -39,7 +40,7 @@ struct Fragment_Shader float4 screenSize; }; constant Uniforms_ShadowUniformBuffer & ShadowUniformBuffer; - texture2d ShadowTexture; + depth2d ShadowTexture; sampler clampMiplessLinearSampler; struct VSOutput { @@ -71,7 +72,7 @@ struct Fragment_Shader float2 offset = float2(shadowSamples[(i * 2)], shadowSamples[((i * 2) + 1)]); (offset = float2((((offset).x * c) + ((offset).y * s)), (((offset).x * (-s)) + ((offset).y * c)))); (offset *= (float2)(shadowFilterSize)); - float shadowMapValue = (float)(ShadowTexture.sample(clampMiplessLinearSampler, ((posLS).xy + offset), level(0))).r; + float shadowMapValue = (float)(ShadowTexture.sample(clampMiplessLinearSampler, ((posLS).xy + offset), level(0))); (shadowFactor += ((((shadowMapValue - 0.0020000000) > (posLS).z))?(0.0):(1.0))); } (shadowFactor *= NUM_SHADOW_SAMPLES_INV); @@ -87,13 +88,13 @@ struct Fragment_Shader }; Fragment_Shader( -constant Uniforms_ShadowUniformBuffer & ShadowUniformBuffer,texture2d ShadowTexture,sampler clampMiplessLinearSampler) : +constant Uniforms_ShadowUniformBuffer & ShadowUniformBuffer,depth2d ShadowTexture,sampler clampMiplessLinearSampler) : ShadowUniformBuffer(ShadowUniformBuffer),ShadowTexture(ShadowTexture),clampMiplessLinearSampler(clampMiplessLinearSampler) {} }; struct Scene { - texture2d ShadowTexture [[id(0)]]; + depth2d ShadowTexture [[id(0)]]; sampler clampMiplessLinearSampler [[id(1)]]; }; diff --git a/Examples_3/Unit_Tests/src/18_Playback/18_Playback.cpp b/Examples_3/Unit_Tests/src/18_Playback/18_Playback.cpp index eba0b029a2..deeab89c20 100644 --- a/Examples_3/Unit_Tests/src/18_Playback/18_Playback.cpp +++ b/Examples_3/Unit_Tests/src/18_Playback/18_Playback.cpp @@ -930,6 +930,7 @@ class Playback: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/19_Blending/19_Blending.cpp b/Examples_3/Unit_Tests/src/19_Blending/19_Blending.cpp index f56530c42c..000a3f4b61 100644 --- a/Examples_3/Unit_Tests/src/19_Blending/19_Blending.cpp +++ b/Examples_3/Unit_Tests/src/19_Blending/19_Blending.cpp @@ -1199,6 +1199,7 @@ class Blending: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/20_JointAttachment/20_JointAttachment.cpp b/Examples_3/Unit_Tests/src/20_JointAttachment/20_JointAttachment.cpp index 883fb0fe3c..dc35ce4b09 100644 --- a/Examples_3/Unit_Tests/src/20_JointAttachment/20_JointAttachment.cpp +++ b/Examples_3/Unit_Tests/src/20_JointAttachment/20_JointAttachment.cpp @@ -1077,6 +1077,7 @@ class JointAttachment: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/21_PartialBlending/21_PartialBlending.cpp b/Examples_3/Unit_Tests/src/21_PartialBlending/21_PartialBlending.cpp index bc3728d3fd..815c3c840f 100644 --- a/Examples_3/Unit_Tests/src/21_PartialBlending/21_PartialBlending.cpp +++ b/Examples_3/Unit_Tests/src/21_PartialBlending/21_PartialBlending.cpp @@ -1153,6 +1153,7 @@ class Blending: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/22_AdditiveBlending/22_AdditiveBlending.cpp b/Examples_3/Unit_Tests/src/22_AdditiveBlending/22_AdditiveBlending.cpp index 1a2786c671..190c4147db 100644 --- a/Examples_3/Unit_Tests/src/22_AdditiveBlending/22_AdditiveBlending.cpp +++ b/Examples_3/Unit_Tests/src/22_AdditiveBlending/22_AdditiveBlending.cpp @@ -1094,6 +1094,7 @@ class AdditiveBlending: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/23_BakedPhysics/23_BakedPhysics.cpp b/Examples_3/Unit_Tests/src/23_BakedPhysics/23_BakedPhysics.cpp index 2df95bd80c..290265cc60 100644 --- a/Examples_3/Unit_Tests/src/23_BakedPhysics/23_BakedPhysics.cpp +++ b/Examples_3/Unit_Tests/src/23_BakedPhysics/23_BakedPhysics.cpp @@ -878,6 +878,7 @@ class BakedPhysics: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/24_MultiThread/24_MultiThread.cpp b/Examples_3/Unit_Tests/src/24_MultiThread/24_MultiThread.cpp index 457e97fa53..b3e0726b9d 100644 --- a/Examples_3/Unit_Tests/src/24_MultiThread/24_MultiThread.cpp +++ b/Examples_3/Unit_Tests/src/24_MultiThread/24_MultiThread.cpp @@ -982,6 +982,7 @@ class MultiThread: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/25_Skinning/25_Skinning.cpp b/Examples_3/Unit_Tests/src/25_Skinning/25_Skinning.cpp index 0519ee847c..295218d9cf 100644 --- a/Examples_3/Unit_Tests/src/25_Skinning/25_Skinning.cpp +++ b/Examples_3/Unit_Tests/src/25_Skinning/25_Skinning.cpp @@ -1168,6 +1168,7 @@ class Skinning: public IApp depthRT.mSampleCount = SAMPLE_COUNT_1; depthRT.mSampleQuality = 0; depthRT.mWidth = mSettings.mWidth; + depthRT.mFlags = TEXTURE_CREATION_FLAG_ON_TILE; addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); return pDepthBuffer != NULL; diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/26_InverseKinematic.cpp b/Examples_3/Unit_Tests/src/26_InverseKinematic/26_InverseKinematic.cpp new file mode 100644 index 0000000000..84b096bb1a --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/26_InverseKinematic.cpp @@ -0,0 +1,1030 @@ +/* +* Copyright (c) 2018-2019 Confetti Interactive Inc. +* +* This file is part of The-Forge +* (see https://github.com/ConfettiFX/The-Forge). +* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +/******************************************************************************************************** +* +* The Forge - ANIMATION - AIM IK UNIT TEST +* +* The purpose of this demo is to show how to do aim inverse kinematics using the +* animnation middleware +* +*********************************************************************************************************/ + +// Interfaces +#include "../../../../Common_3/OS/Interfaces/ICameraController.h" +#include "../../../../Common_3/OS/Interfaces/IApp.h" +#include "../../../../Common_3/OS/Interfaces/ILog.h" +#include "../../../../Common_3/OS/Interfaces/IFileSystem.h" +#include "../../../../Common_3/OS/Interfaces/ITime.h" +#include "../../../../Common_3/OS/Interfaces/IProfiler.h" +#include "../../../../Common_3/OS/Interfaces/IInput.h" + +// Rendering +#include "../../../../Common_3/Renderer/IRenderer.h" +#include "../../../../Common_3/Renderer/ResourceLoader.h" + +// Middleware packages +#include "../../../../Middleware_3/Animation/SkeletonBatcher.h" +#include "../../../../Middleware_3/Animation/AnimatedObject.h" +#include "../../../../Middleware_3/Animation/Animation.h" +#include "../../../../Middleware_3/Animation/Clip.h" +#include "../../../../Middleware_3/Animation/ClipController.h" +#include "../../../../Middleware_3/Animation/Rig.h" + +#include "../../../../Middleware_3/UI/AppUI.h" +// tiny stl +#include "../../../../Common_3/ThirdParty/OpenSource/EASTL/vector.h" +#include "../../../../Common_3/ThirdParty/OpenSource/EASTL/string.h" + +// Math +#include "../../../../Common_3/OS/Math/MathTypes.h" + +// Memory +#include "../../../../Common_3/OS/Interfaces/IMemory.h" + +const char* pszBases[FSR_Count] = { + "../../../src/26_InverseKinematic/", // FSR_BinShaders + "../../../src/26_InverseKinematic/", // FSR_SrcShaders + "../../../UnitTestResources/", // FSR_Textures + "../../../UnitTestResources/", // FSR_Meshes + "../../../UnitTestResources/", // FSR_Builtin_Fonts + "../../../src/26_InverseKinematic/", // FSR_GpuConfig + "../../../UnitTestResources/", // FSR_Animation + "", // FSR_Audio + "", // FSR_OtherFiles + "../../../../../Middleware_3/Text/", // FSR_MIDDLEWARE_TEXT + "../../../../../Middleware_3/UI/", // FSR_MIDDLEWARE_UI +}; + +//-------------------------------------------------------------------------------------------- +// RENDERING PIPELINE DATA +//-------------------------------------------------------------------------------------------- +const uint32_t gImageCount = 3; +bool gMicroProfiler = false; +bool bPrevToggleMicroProfiler = false; + +uint32_t gFrameIndex = 0; +Renderer* pRenderer = NULL; + +Queue* pGraphicsQueue = NULL; +CmdPool* pCmdPool = NULL; +Cmd** ppCmds = NULL; + +SwapChain* pSwapChain = NULL; +RenderTarget* pDepthBuffer = NULL; +Fence* pRenderCompleteFences[gImageCount] = { NULL }; +Semaphore* pImageAcquiredSemaphore = NULL; +Semaphore* pRenderCompleteSemaphores[gImageCount] = { NULL }; + +VirtualJoystickUI gVirtualJoystick; +DepthState* pDepth = NULL; + +RasterizerState* pPlaneRast = NULL; +RasterizerState* pSkeletonRast = NULL; + +Shader* pSkeletonShader = NULL; +Buffer* pJointVertexBuffer = NULL; +Buffer* pBoneVertexBuffer = NULL; +Pipeline* pSkeletonPipeline = NULL; +int gNumberOfJointPoints; +int gNumberOfBonePoints; + +Shader* pPlaneDrawShader = NULL; +Buffer* pPlaneVertexBuffer = NULL; +Pipeline* pPlaneDrawPipeline = NULL; +RootSignature* pRootSignature = NULL; +DescriptorSet* pDescriptorSetPlane = NULL; +DescriptorSet* pDescriptorSetTarget = NULL; + +struct UniformBlockPlane +{ + mat4 mProjectView; + mat4 mToWorldMat; +}; +UniformBlockPlane gUniformDataPlane; + +Buffer* pPlaneUniformBuffer[gImageCount] = { NULL }; + +//-------------------------------------------------------------------------------------------- +// CAMERA CONTROLLER & SYSTEMS (File/Log/UI) +//-------------------------------------------------------------------------------------------- + +ICameraController* pCameraController = NULL; +UIApp gAppUI; +GuiComponent* pStandaloneControlsGUIWindow = NULL; + +TextDrawDesc gFrameTimeDraw = TextDrawDesc(0, 0xff00ffff, 18); +GpuProfiler* pGpuProfiler = NULL; + +//-------------------------------------------------------------------------------------------- +// ANIMATION DATA +//-------------------------------------------------------------------------------------------- + +// AnimatedObjects +AnimatedObject gStickFigureAnimObject; + +// Animations +Animation gStandAnimation; + +// ClipControllers +ClipController gStandClipController; + +// Clips +Clip gStandClip; + +// Rigs +Rig gStickFigureRig; + +// SkeletonBatcher +SkeletonBatcher gSkeletonBatcher; + +// parameters for aim IK +AimIKDesc gAimIKDesc; +TwoBonesIKDesc gTwoBonesIKDesc; +int gJointChain[4]; +const Vector3 gJointUpVectors[4] = { Vector3::xAxis(), Vector3::xAxis(), Vector3::xAxis(), Vector3::xAxis() }; +//-------------------------------------------------------------------------------------------- +// TARGET +//-------------------------------------------------------------------------------------------- + +UniformSkeletonBlock gUniformDataTarget; + +Buffer* pTargetUniformBuffer[gImageCount] = { NULL }; + +// Filenames +const char* gStickFigureName = "stickFigure/skeleton.ozz"; +const char* gStandClipName = "stickFigure/animations/stand.ozz"; +const char* pPlaneImageFileName = "Skybox_right1"; + +const int gSphereResolution = 30; // Increase for higher resolution joint spheres +const float gBoneWidthRatio = 0.2f; // Determines how far along the bone to put the max width [0,1] +const float gJointRadius = gBoneWidthRatio * 0.5f; // set to replicate Ozz skeleton + +// Timer to get animationsystem update time +static HiresTimer gAnimationUpdateTimer; + +//-------------------------------------------------------------------------------------------- +// UI DATA +//-------------------------------------------------------------------------------------------- +struct UIData +{ + struct IKParamsData + { + bool mAim = true; + float mFoot; + }; + IKParamsData mIKParams; + + struct BlendParamsData + { + bool* mAutoSetBlendParams; + float* mStandClipWeight; + float* mThreshold; + }; + BlendParamsData mBlendParams; + + struct ClipData + { + bool* mPlay; + bool* mLoop; + float mAnimationTime; // will get set by clip controller + float* mPlaybackSpeed; + }; + ClipData mStandClip; + + struct GeneralSettingsData + { + bool mShowBindPose = false; //false; + bool mDrawPlane = true; + }; + GeneralSettingsData mGeneralSettings; +}; +UIData gUIData; + +// Hard set the controller's time ratio via callback when it is set in the UI +void StandClipTimeChangeCallback() { gStandClipController.SetTimeRatioHard(gUIData.mStandClip.mAnimationTime); } + +//-------------------------------------------------------------------------------------------- +// APP CODE +//-------------------------------------------------------------------------------------------- +class AimIK: public IApp +{ + public: + bool Init() + { + // WINDOW AND RENDERER SETUP + // + RendererDesc settings = { 0 }; + initRenderer(GetName(), &settings, &pRenderer); + if (!pRenderer) //check for init success + return false; + + // CREATE COMMAND LIST AND GRAPHICS/COMPUTE QUEUES + // + QueueDesc queueDesc = {}; + queueDesc.mType = CMD_POOL_DIRECT; + addQueue(pRenderer, &queueDesc, &pGraphicsQueue); + addCmdPool(pRenderer, pGraphicsQueue, false, &pCmdPool); + addCmd_n(pCmdPool, false, gImageCount, &ppCmds); + + for (uint32_t i = 0; i < gImageCount; ++i) + { + addFence(pRenderer, &pRenderCompleteFences[i]); + addSemaphore(pRenderer, &pRenderCompleteSemaphores[i]); + } + addSemaphore(pRenderer, &pImageAcquiredSemaphore); + + + // INITIALIZE RESOURCE/DEBUG SYSTEMS + // + initResourceLoaderInterface(pRenderer); + + if (!gVirtualJoystick.Init(pRenderer, "circlepad", FSR_Textures)) + return false; + + // INITIALIZE THE USER INTERFACE + // + if (!gAppUI.Init(pRenderer)) + return false; + + gAppUI.LoadFont("TitilliumText/TitilliumText-Bold.otf", FSR_Builtin_Fonts); + + initProfiler(); + + addGpuProfiler(pRenderer, pGraphicsQueue, &pGpuProfiler, "GpuProfiler"); + + // INITIALIZE PIPILINE STATES + // + ShaderLoadDesc planeShader = {}; + planeShader.mStages[0] = { "plane.vert", NULL, 0, FSR_SrcShaders }; + planeShader.mStages[1] = { "plane.frag", NULL, 0, FSR_SrcShaders }; + ShaderLoadDesc basicShader = {}; + basicShader.mStages[0] = { "basic.vert", NULL, 0, FSR_SrcShaders }; + basicShader.mStages[1] = { "basic.frag", NULL, 0, FSR_SrcShaders }; + + addShader(pRenderer, &planeShader, &pPlaneDrawShader); + addShader(pRenderer, &basicShader, &pSkeletonShader); + + Shader* shaders[] = { pSkeletonShader, pPlaneDrawShader }; + RootSignatureDesc rootDesc = {}; + rootDesc.mShaderCount = 2; + rootDesc.ppShaders = shaders; + addRootSignature(pRenderer, &rootDesc, &pRootSignature); + + DescriptorSetDesc setDesc = { pRootSignature, DESCRIPTOR_UPDATE_FREQ_PER_DRAW, gImageCount }; + addDescriptorSet(pRenderer, &setDesc, &pDescriptorSetPlane); + addDescriptorSet(pRenderer, &setDesc, &pDescriptorSetTarget); + + RasterizerStateDesc rasterizerStateDesc = {}; + rasterizerStateDesc.mCullMode = CULL_MODE_NONE; + addRasterizerState(pRenderer, &rasterizerStateDesc, &pPlaneRast); + + RasterizerStateDesc skeletonRasterizerStateDesc = {}; + skeletonRasterizerStateDesc.mCullMode = CULL_MODE_FRONT; + addRasterizerState(pRenderer, &skeletonRasterizerStateDesc, &pSkeletonRast); + + DepthStateDesc depthStateDesc = {}; + depthStateDesc.mDepthTest = true; + depthStateDesc.mDepthWrite = true; + depthStateDesc.mDepthFunc = CMP_LEQUAL; + addDepthState(pRenderer, &depthStateDesc, &pDepth); + + // GENERATE VERTEX BUFFERS + // + + // Generate joint vertex buffer + float* pJointPoints; + generateSpherePoints(&pJointPoints, &gNumberOfJointPoints, gSphereResolution, gJointRadius); + + uint64_t jointDataSize = gNumberOfJointPoints * sizeof(float); + BufferLoadDesc jointVbDesc = {}; + jointVbDesc.mDesc.mDescriptors = DESCRIPTOR_TYPE_VERTEX_BUFFER; + jointVbDesc.mDesc.mMemoryUsage = RESOURCE_MEMORY_USAGE_GPU_ONLY; + jointVbDesc.mDesc.mSize = jointDataSize; + jointVbDesc.mDesc.mVertexStride = sizeof(float) * 6; + jointVbDesc.pData = pJointPoints; + jointVbDesc.ppBuffer = &pJointVertexBuffer; + addResource(&jointVbDesc); + + // Need to free memory; + conf_free(pJointPoints); + + // Generate bone vertex buffer + float* pBonePoints; + generateBonePoints(&pBonePoints, &gNumberOfBonePoints, gBoneWidthRatio); + + uint64_t boneDataSize = gNumberOfBonePoints * sizeof(float); + BufferLoadDesc boneVbDesc = {}; + boneVbDesc.mDesc.mDescriptors = DESCRIPTOR_TYPE_VERTEX_BUFFER; + boneVbDesc.mDesc.mMemoryUsage = RESOURCE_MEMORY_USAGE_GPU_ONLY; + boneVbDesc.mDesc.mSize = boneDataSize; + boneVbDesc.mDesc.mVertexStride = sizeof(float) * 6; + boneVbDesc.pData = pBonePoints; + boneVbDesc.ppBuffer = &pBoneVertexBuffer; + addResource(&boneVbDesc); + + // Need to free memory; + conf_free(pBonePoints); + + //Generate plane vertex buffer + float planePoints[] = { -10.0f, 0.0f, -10.0f, 1.0f, 0.0f, 0.0f, -10.0f, 0.0f, 10.0f, 1.0f, 1.0f, 0.0f, + 10.0f, 0.0f, 10.0f, 1.0f, 1.0f, 1.0f, 10.0f, 0.0f, 10.0f, 1.0f, 1.0f, 1.0f, + 10.0f, 0.0f, -10.0f, 1.0f, 0.0f, 1.0f, -10.0f, 0.0f, -10.0f, 1.0f, 0.0f, 0.0f }; + + uint64_t planeDataSize = 6 * 6 * sizeof(float); + BufferLoadDesc planeVbDesc = {}; + planeVbDesc.mDesc.mDescriptors = DESCRIPTOR_TYPE_VERTEX_BUFFER; + planeVbDesc.mDesc.mMemoryUsage = RESOURCE_MEMORY_USAGE_GPU_ONLY; + planeVbDesc.mDesc.mSize = planeDataSize; + planeVbDesc.mDesc.mVertexStride = sizeof(float) * 6; + planeVbDesc.pData = planePoints; + planeVbDesc.ppBuffer = &pPlaneVertexBuffer; + addResource(&planeVbDesc); + + BufferLoadDesc ubDesc = {}; + ubDesc.mDesc.mDescriptors = DESCRIPTOR_TYPE_UNIFORM_BUFFER; + ubDesc.mDesc.mMemoryUsage = RESOURCE_MEMORY_USAGE_CPU_TO_GPU; + ubDesc.mDesc.mSize = sizeof(UniformBlockPlane); + ubDesc.mDesc.mFlags = BUFFER_CREATION_FLAG_PERSISTENT_MAP_BIT; + ubDesc.pData = NULL; + for (uint32_t i = 0; i < gImageCount; ++i) + { + ubDesc.ppBuffer = &pPlaneUniformBuffer[i]; + addResource(&ubDesc); + } + ubDesc.mDesc.mSize = sizeof(UniformSkeletonBlock); + for (uint32_t i = 0; i < gImageCount; ++i) + { + ubDesc.ppBuffer = &pTargetUniformBuffer[i]; + addResource(&ubDesc); + } + + /************************************************************************/ + // SETUP ANIMATION STRUCTURES + /************************************************************************/ + + // SKELETON RENDERER + // + + // Set up details for rendering the skeletons + SkeletonRenderDesc skeletonRenderDesc = {}; + skeletonRenderDesc.mRenderer = pRenderer; + skeletonRenderDesc.mSkeletonPipeline = pSkeletonPipeline; + skeletonRenderDesc.mRootSignature = pRootSignature; + skeletonRenderDesc.mJointVertexBuffer = pJointVertexBuffer; + skeletonRenderDesc.mNumJointPoints = gNumberOfJointPoints; + skeletonRenderDesc.mDrawBones = true; + skeletonRenderDesc.mBoneVertexBuffer = pBoneVertexBuffer; + skeletonRenderDesc.mNumBonePoints = gNumberOfBonePoints; + + gSkeletonBatcher.Initialize(skeletonRenderDesc); + + // RIGS + // + eastl::string fullPath = FileSystem::FixPath(gStickFigureName, FSR_Animation); + + // Initialize the rig with the path to its ozz file + gStickFigureRig.Initialize(fullPath.c_str()); + + // Add the rig to the list of skeletons to render + gSkeletonBatcher.AddRig(&gStickFigureRig); + + // CLIPS + // + fullPath = FileSystem::FixPath(gStandClipName, FSR_Animation); + + gStandClip.Initialize(fullPath.c_str(), &gStickFigureRig); + + // CLIP CONTROLLERS + // + // Initialize with the length of the clip they are controlling and an + // optional external time to set based on their updating + gStandClipController.Initialize(gStandClip.GetDuration(), &gUIData.mStandClip.mAnimationTime); + + // ANIMATIONS + // + AnimationDesc animationDesc{}; + animationDesc.mRig = &gStickFigureRig; + animationDesc.mNumLayers = 1; + animationDesc.mLayerProperties[0].mClip = &gStandClip; + animationDesc.mLayerProperties[0].mClipController = &gStandClipController; + + gStandAnimation.Initialize(animationDesc); + + // ANIMATED OBJECTS + // + gStickFigureAnimObject.Initialize(&gStickFigureRig, &gStandAnimation); + + const char* aimJointNames[4] = { "Head", "Spine3", "Spine2", "Spine1" }; + gAimIKDesc.mForward = Vector3::yAxis(); + gAimIKDesc.mOffset = Vector3(.07f, .1f, 0.f); + gAimIKDesc.mPoleVector = Vector3::yAxis(); + gAimIKDesc.mTwistAngle = 0.0f; + gAimIKDesc.mJointWeight = 0.5f; + gAimIKDesc.mJointChainLength = 4; + gAimIKDesc.mJointChain = gJointChain; + gAimIKDesc.mJointUpVectors = gJointUpVectors; + gStickFigureRig.FindJointChain(aimJointNames, gAimIKDesc.mJointChainLength, gJointChain); + + const char* twoBonesJointNames[] = { "RightUpLeg", "RightLeg", "RightFoot" }; + gTwoBonesIKDesc.mSoften = 1.0f; + gTwoBonesIKDesc.mWeight = 1.0f; + gTwoBonesIKDesc.mTwistAngle = 0.0f; + gTwoBonesIKDesc.mPoleVector = Vector3::zAxis(); + gTwoBonesIKDesc.mMidAxis = Vector3::zAxis(); + gStickFigureRig.FindJointChain(twoBonesJointNames, 3, gTwoBonesIKDesc.mJointChain); + /************************************************************************/ + + finishResourceLoading(); + + // SETUP THE MAIN CAMERA + // + CameraMotionParameters cmp{ 50.0f, 75.0f, 150.0f }; + vec3 camPos{ -3.0f, 3.0f, 3.0f }; + vec3 lookAt{ 0.0f, 1.0f, 0.0f }; + + pCameraController = createFpsCameraController(camPos, lookAt); + pCameraController->setMotionParameters(cmp); + + + + // Add the GUI Panels/Windows + const TextDrawDesc UIPanelWindowTitleTextDesc = { 0, 0xffff00ff, 16 }; + + vec2 UIPosition = { mSettings.mWidth * 0.01f, mSettings.mHeight * 0.05f }; + vec2 UIPanelSize = { 650, 1000 }; + GuiDesc guiDesc(UIPosition, UIPanelSize, UIPanelWindowTitleTextDesc); + pStandaloneControlsGUIWindow = gAppUI.AddGuiComponent("Stand Animation", &guiDesc); + + pStandaloneControlsGUIWindow->AddWidget(CheckboxWidget("Toggle Micro Profiler", &gMicroProfiler)); + + // SET gUIData MEMBERS THAT NEED POINTERS TO ANIMATION DATA + // + + // Blend Params + gUIData.mBlendParams.mAutoSetBlendParams = gStandAnimation.GetAutoSetBlendParamsPtr(); + + gUIData.mBlendParams.mStandClipWeight = gStandClipController.GetWeightPtr(); + gUIData.mBlendParams.mThreshold = gStandAnimation.GetThresholdPtr(); + + // Stand Clip + gUIData.mStandClip.mPlay = gStandClipController.GetPlayPtr(); + gUIData.mStandClip.mLoop = gStandClipController.GetLoopPtr(); + gUIData.mStandClip.mPlaybackSpeed = gStandClipController.GetPlaybackSpeedPtr(); + + // SET UP GUI BASED ON gUIData STRUCT + // + { + // INVERSE KINEMATICS + // + CollapsingHeaderWidget CollapsingIKWidgets("Inverse Kinematics"); + CollapsingIKWidgets.SetCollapsed(false); + CollapsingIKWidgets.AddSubWidget(CheckboxWidget("Aim IK", &gUIData.mIKParams.mAim)); + float sliderStepSize = 0.01f; + SliderFloatWidget SliderFootIK("Foot two bone IK", &gUIData.mIKParams.mFoot, 0.0f, 0.5f, sliderStepSize); + CollapsingIKWidgets.AddSubWidget(SliderFootIK); + + // BLEND PARAMETERS + // + CollapsingHeaderWidget CollapsingBlendParamsWidgets("Blend Parameters"); + + // AutoSetBlendParams - Checkbox + CollapsingBlendParamsWidgets.AddSubWidget(SeparatorWidget()); + CollapsingBlendParamsWidgets.AddSubWidget(CheckboxWidget("Auto Set Blend Params", gUIData.mBlendParams.mAutoSetBlendParams)); + + // Stand Clip Weight - Slider + float fValMin = 0.0f; + float fValMax = 1.0f; + + CollapsingBlendParamsWidgets.AddSubWidget(SeparatorWidget()); + CollapsingBlendParamsWidgets.AddSubWidget( + SliderFloatWidget("Clip Weight [Stand]", gUIData.mBlendParams.mStandClipWeight, fValMin, fValMax, sliderStepSize)); + + // Threshold - Slider + fValMin = 0.01f; + fValMax = 1.0f; + sliderStepSize = 0.01f; + + CollapsingBlendParamsWidgets.AddSubWidget(SeparatorWidget()); + CollapsingBlendParamsWidgets.AddSubWidget( + SliderFloatWidget("Threshold", gUIData.mBlendParams.mThreshold, fValMin, fValMax, sliderStepSize)); + CollapsingBlendParamsWidgets.AddSubWidget(SeparatorWidget()); + + // STAND CLIP + // + CollapsingHeaderWidget CollapsingStandClipWidgets("Stand Clip"); + + // Play/Pause - Checkbox + CollapsingStandClipWidgets.AddSubWidget(SeparatorWidget()); + CollapsingStandClipWidgets.AddSubWidget(CheckboxWidget("Play", gUIData.mStandClip.mPlay)); + + // Loop - Checkbox + CollapsingStandClipWidgets.AddSubWidget(SeparatorWidget()); + CollapsingStandClipWidgets.AddSubWidget(CheckboxWidget("Loop", gUIData.mStandClip.mLoop)); + + // Animation Time - Slider + fValMin = 0.0f; + fValMax = gStandClipController.GetDuration(); + sliderStepSize = 0.01f; + SliderFloatWidget SliderAnimationTime("Animation Time", &gUIData.mStandClip.mAnimationTime, fValMin, fValMax, sliderStepSize); + SliderAnimationTime.pOnActive = StandClipTimeChangeCallback; + + CollapsingStandClipWidgets.AddSubWidget(SeparatorWidget()); + CollapsingStandClipWidgets.AddSubWidget(SliderAnimationTime); + + // Playback Speed - Slider + fValMin = -5.0f; + fValMax = 5.0f; + sliderStepSize = 0.1f; + + CollapsingStandClipWidgets.AddSubWidget(SeparatorWidget()); + CollapsingStandClipWidgets.AddSubWidget( + SliderFloatWidget("Playback Speed", gUIData.mStandClip.mPlaybackSpeed, fValMin, fValMax, sliderStepSize)); + CollapsingStandClipWidgets.AddSubWidget(SeparatorWidget()); + + // GENERAL SETTINGS + // + CollapsingHeaderWidget CollapsingGeneralSettingsWidgets("General Settings"); + + // ShowBindPose - Checkbox + CollapsingGeneralSettingsWidgets.AddSubWidget(SeparatorWidget()); + CollapsingGeneralSettingsWidgets.AddSubWidget(CheckboxWidget("Show Bind Pose", &gUIData.mGeneralSettings.mShowBindPose)); + + // DrawPlane - Checkbox + CollapsingGeneralSettingsWidgets.AddSubWidget(SeparatorWidget()); + CollapsingGeneralSettingsWidgets.AddSubWidget(CheckboxWidget("Draw Plane", &gUIData.mGeneralSettings.mDrawPlane)); + CollapsingGeneralSettingsWidgets.AddSubWidget(SeparatorWidget()); + + // Add all widgets to the window + pStandaloneControlsGUIWindow->AddWidget(CollapsingIKWidgets); + pStandaloneControlsGUIWindow->AddWidget(CollapsingBlendParamsWidgets); + pStandaloneControlsGUIWindow->AddWidget(CollapsingStandClipWidgets); + pStandaloneControlsGUIWindow->AddWidget(CollapsingGeneralSettingsWidgets); + } + + if (!initInputSystem(pWindow)) + return false; + + // App Actions + InputActionDesc actionDesc = { InputBindings::BUTTON_FULLSCREEN, [](InputActionContext* ctx) { toggleFullscreen(((IApp*)ctx->pUserData)->pWindow); return true; }, this }; + addInputAction(&actionDesc); + actionDesc = { InputBindings::BUTTON_EXIT, [](InputActionContext* ctx) { requestShutdown(); return true; } }; + addInputAction(&actionDesc); + actionDesc = + { + InputBindings::BUTTON_ANY, [](InputActionContext* ctx) + { + bool capture = gAppUI.OnButton(ctx->mBinding, ctx->mBool, ctx->pPosition); + setEnableCaptureInput(capture && INPUT_ACTION_PHASE_CANCELED != ctx->mPhase); + return true; + }, this + }; + addInputAction(&actionDesc); + typedef bool (*CameraInputHandler)(InputActionContext* ctx, uint32_t index); + static CameraInputHandler onCameraInput = [](InputActionContext* ctx, uint32_t index) + { + if (!gMicroProfiler && !gAppUI.IsFocused() && *ctx->pCaptured) + { + gVirtualJoystick.OnMove(index, ctx->mPhase != INPUT_ACTION_PHASE_CANCELED, ctx->pPosition); + index ? pCameraController->onRotate(ctx->mFloat2) : pCameraController->onMove(ctx->mFloat2); + } + return true; + }; + actionDesc = { InputBindings::FLOAT_RIGHTSTICK, [](InputActionContext* ctx) { return onCameraInput(ctx, 1); }, NULL, 20.0f, 200.0f, 0.5f }; + addInputAction(&actionDesc); + actionDesc = { InputBindings::FLOAT_LEFTSTICK, [](InputActionContext* ctx) { return onCameraInput(ctx, 0); }, NULL, 20.0f, 200.0f, 1.0f }; + addInputAction(&actionDesc); + actionDesc = { InputBindings::BUTTON_NORTH, [](InputActionContext* ctx) { pCameraController->resetView(); return true; } }; + addInputAction(&actionDesc); + + // Prepare descriptor sets + for (uint32_t i = 0; i < gImageCount; ++i) + { + DescriptorData params[1] = {}; + params[0].pName = "uniformBlock"; + params[0].ppBuffers = &pPlaneUniformBuffer[i]; + updateDescriptorSet(pRenderer, i, pDescriptorSetPlane, 1, params); + params[0].ppBuffers = &pTargetUniformBuffer[gFrameIndex]; + updateDescriptorSet(pRenderer, i, pDescriptorSetTarget, 1, params); + } + + return true; + } + + void Exit() + { + // wait for rendering to finish before freeing resources + waitQueueIdle(pGraphicsQueue); + + exitInputSystem(); + + exitProfiler(); + + // Animation data + gSkeletonBatcher.Destroy(); + gStickFigureRig.Destroy(); + gStandClip.Destroy(); + gStandAnimation.Destroy(); + gStickFigureAnimObject.Destroy(); + + destroyCameraController(pCameraController); + + gVirtualJoystick.Exit(); + + removeGpuProfiler(pRenderer, pGpuProfiler); + + gAppUI.Exit(); + + for (uint32_t i = 0; i < gImageCount; ++i) + { + removeResource(pPlaneUniformBuffer[i]); + } + for (uint32_t i = 0; i < gImageCount; ++i) + { + removeResource(pTargetUniformBuffer[i]); + } + + removeResource(pJointVertexBuffer); + removeResource(pBoneVertexBuffer); + removeResource(pPlaneVertexBuffer); + + removeShader(pRenderer, pSkeletonShader); + removeShader(pRenderer, pPlaneDrawShader); + removeRootSignature(pRenderer, pRootSignature); + removeDescriptorSet(pRenderer, pDescriptorSetPlane); + removeDescriptorSet(pRenderer, pDescriptorSetTarget); + + removeDepthState(pDepth); + + removeRasterizerState(pSkeletonRast); + removeRasterizerState(pPlaneRast); + + for (uint32_t i = 0; i < gImageCount; ++i) + { + removeFence(pRenderer, pRenderCompleteFences[i]); + removeSemaphore(pRenderer, pRenderCompleteSemaphores[i]); + } + removeSemaphore(pRenderer, pImageAcquiredSemaphore); + + removeCmd_n(pCmdPool, gImageCount, ppCmds); + removeCmdPool(pRenderer, pCmdPool); + + removeResourceLoaderInterface(pRenderer); + removeQueue(pGraphicsQueue); + removeRenderer(pRenderer); + } + + bool Load() + { + // INITIALIZE SWAP-CHAIN AND DEPTH BUFFER + // + if (!addSwapChain()) + return false; + if (!addDepthBuffer()) + return false; + + // LOAD USER INTERFACE + // + if (!gAppUI.Load(pSwapChain->ppSwapchainRenderTargets)) + return false; + + if (!gVirtualJoystick.Load(pSwapChain->ppSwapchainRenderTargets[0])) + return false; + + loadProfiler(&gAppUI, mSettings.mWidth, mSettings.mHeight); + + //layout and pipeline for skeleton draw + VertexLayout vertexLayout = {}; + vertexLayout.mAttribCount = 2; + vertexLayout.mAttribs[0].mSemantic = SEMANTIC_POSITION; + vertexLayout.mAttribs[0].mFormat = TinyImageFormat_R32G32B32_SFLOAT; + vertexLayout.mAttribs[0].mBinding = 0; + vertexLayout.mAttribs[0].mLocation = 0; + vertexLayout.mAttribs[0].mOffset = 0; + vertexLayout.mAttribs[1].mSemantic = SEMANTIC_NORMAL; + vertexLayout.mAttribs[1].mFormat = TinyImageFormat_R32G32B32_SFLOAT; + vertexLayout.mAttribs[1].mBinding = 0; + vertexLayout.mAttribs[1].mLocation = 1; + vertexLayout.mAttribs[1].mOffset = 3 * sizeof(float); + + PipelineDesc desc = {}; + desc.mType = PIPELINE_TYPE_GRAPHICS; + GraphicsPipelineDesc& pipelineSettings = desc.mGraphicsDesc; + pipelineSettings.mPrimitiveTopo = PRIMITIVE_TOPO_TRI_LIST; + pipelineSettings.mRenderTargetCount = 1; + pipelineSettings.pDepthState = pDepth; + pipelineSettings.pColorFormats = &pSwapChain->ppSwapchainRenderTargets[0]->mDesc.mFormat; + pipelineSettings.mSampleCount = pSwapChain->ppSwapchainRenderTargets[0]->mDesc.mSampleCount; + pipelineSettings.mSampleQuality = pSwapChain->ppSwapchainRenderTargets[0]->mDesc.mSampleQuality; + pipelineSettings.mDepthStencilFormat = pDepthBuffer->mDesc.mFormat; + pipelineSettings.pRootSignature = pRootSignature; + pipelineSettings.pShaderProgram = pSkeletonShader; + pipelineSettings.pVertexLayout = &vertexLayout; + pipelineSettings.pRasterizerState = pSkeletonRast; + addPipeline(pRenderer, &desc, &pSkeletonPipeline); + + // Update the mSkeletonPipeline pointer now that the pipeline has been loaded + gSkeletonBatcher.LoadPipeline(pSkeletonPipeline); + + //layout and pipeline for plane draw + vertexLayout = {}; + vertexLayout.mAttribCount = 2; + vertexLayout.mAttribs[0].mSemantic = SEMANTIC_POSITION; + vertexLayout.mAttribs[0].mFormat = TinyImageFormat_R32G32B32A32_SFLOAT; + vertexLayout.mAttribs[0].mBinding = 0; + vertexLayout.mAttribs[0].mLocation = 0; + vertexLayout.mAttribs[0].mOffset = 0; + vertexLayout.mAttribs[1].mSemantic = SEMANTIC_TEXCOORD0; + vertexLayout.mAttribs[1].mFormat = TinyImageFormat_R32G32_SFLOAT; + vertexLayout.mAttribs[1].mBinding = 0; + vertexLayout.mAttribs[1].mLocation = 1; + vertexLayout.mAttribs[1].mOffset = 4 * sizeof(float); + + pipelineSettings.pDepthState = NULL; + pipelineSettings.pRasterizerState = pPlaneRast; + pipelineSettings.pShaderProgram = pPlaneDrawShader; + addPipeline(pRenderer, &desc, &pPlaneDrawPipeline); + + return true; + } + + void Unload() + { + waitQueueIdle(pGraphicsQueue); + + unloadProfiler(); + gAppUI.Unload(); + + gVirtualJoystick.Unload(); + + removePipeline(pRenderer, pPlaneDrawPipeline); + removePipeline(pRenderer, pSkeletonPipeline); + + removeSwapChain(pRenderer, pSwapChain); + removeRenderTarget(pRenderer, pDepthBuffer); + } + + void Update(float deltaTime) + { + updateInputSystem(mSettings.mWidth, mSettings.mHeight); + + pCameraController->update(deltaTime); + + /************************************************************************/ + // Scene Update + /************************************************************************/ + + // update camera with time + mat4 viewMat = pCameraController->getViewMatrix(); + + const float aspectInverse = (float)mSettings.mHeight / (float)mSettings.mWidth; + const float horizontal_fov = PI / 2.0f; + mat4 projMat = mat4::perspective(horizontal_fov, aspectInverse, 0.1f, 1000.0f); + mat4 projViewMat = projMat * viewMat; + + vec3 lightPos = vec3(0.0f, 1000.0f, 0.0f); + vec3 lightColor = vec3(1.0f, 1.0f, 1.0f); + + /************************************************************************/ + // Animation + /************************************************************************/ + gAnimationUpdateTimer.Reset(); + + // Update the animated object for this frame + if (!gStickFigureAnimObject.Update(deltaTime)) + LOGF(eINFO, "Animation NOT Updating!"); + + static float time = 0.0f; + time += 2.0f * deltaTime; + + const Point3 aimTarget = Vector3(.2f, 1.5f, -.3f) + Point3(sin(time * .5f), cos(time * .25f), cos(time) * .5f + .5f); + + gUniformDataTarget.mProjectView = projViewMat; + gUniformDataTarget.mLightPosition = Vector4(lightPos); + gUniformDataTarget.mLightColor = Vector4(lightColor); + gUniformDataTarget.mToWorldMat[0] = Matrix4(Matrix3::identity() * 0.25f, Vector3(aimTarget)); + gUniformDataTarget.mColor[0] = Vector4(1.0f, 0.0f, 0.0f, 1.0f); + + if (gUIData.mIKParams.mAim) + { + if (!gStickFigureAnimObject.AimIK(&gAimIKDesc, aimTarget)) + LOGF(eINFO, "Aim IK failed!"); + } + + Matrix4 mat = gStickFigureRig.GetJointModelMats()[gTwoBonesIKDesc.mJointChain[2]]; + Point3 twoBoneTarget = Point3(mat.getCol3().get128()) + Vector3(0.0f, gUIData.mIKParams.mFoot, 0.0f); + + if (!gStickFigureAnimObject.TwoBonesIK(&gTwoBonesIKDesc, twoBoneTarget)) + LOGF(eINFO, "Two bone IK failed!"); + + if (!gUIData.mGeneralSettings.mShowBindPose) + { + // Pose the rig based on the animated object's updated values + gStickFigureAnimObject.PoseRig(); + } + else + { + // Ignore the updated values and pose in bind + gStickFigureAnimObject.PoseRigInBind(); + } + + // Record animation update time + gAnimationUpdateTimer.GetUSec(true); + + // Update uniforms that will be shared between all skeletons + gSkeletonBatcher.SetSharedUniforms(projViewMat, lightPos, lightColor); + + /************************************************************************/ + // Plane + /************************************************************************/ + gUniformDataPlane.mProjectView = projViewMat; + gUniformDataPlane.mToWorldMat = mat4::identity(); + + if (gMicroProfiler != bPrevToggleMicroProfiler) + { + toggleProfiler(); + bPrevToggleMicroProfiler = gMicroProfiler; + } + + /************************************************************************/ + // GUI + /************************************************************************/ + gAppUI.Update(deltaTime); + } + + void Draw() + { + // CPU profiler timer + static HiresTimer gTimer; + + acquireNextImage(pRenderer, pSwapChain, pImageAcquiredSemaphore, NULL, &gFrameIndex); + + // UPDATE UNIFORM BUFFERS + // + + // Update all the instanced uniform data for each batch of joints and bones + gSkeletonBatcher.SetPerInstanceUniforms(gFrameIndex); + + BufferUpdateDesc planeViewProjCbv = { pPlaneUniformBuffer[gFrameIndex], &gUniformDataPlane }; + updateResource(&planeViewProjCbv); + BufferUpdateDesc targetViewProjCbv = { pTargetUniformBuffer[gFrameIndex], &gUniformDataTarget }; + updateResource(&targetViewProjCbv); + + // FRAME SYNC & ACQUIRE SWAPCHAIN RENDER TARGET + // + // Stall if CPU is running "Swap Chain Buffer Count" frames ahead of GPU + Fence* pNextFence = pRenderCompleteFences[gFrameIndex]; + FenceStatus fenceStatus; + getFenceStatus(pRenderer, pNextFence, &fenceStatus); + if (fenceStatus == FENCE_STATUS_INCOMPLETE) + waitForFences(pRenderer, 1, &pNextFence); + + // Acquire the main render target from the swapchain + RenderTarget* pRenderTarget = pSwapChain->ppSwapchainRenderTargets[gFrameIndex]; + Semaphore* pRenderCompleteSemaphore = pRenderCompleteSemaphores[gFrameIndex]; + Fence* pRenderCompleteFence = pRenderCompleteFences[gFrameIndex]; + Cmd* cmd = ppCmds[gFrameIndex]; + beginCmd(cmd); // start recording commands + + // start gpu frame profiler + cmdBeginGpuFrameProfile(cmd, pGpuProfiler); + + TextureBarrier barriers[] = // wait for resource transition + { + { pRenderTarget->pTexture, RESOURCE_STATE_RENDER_TARGET }, + { pDepthBuffer->pTexture, RESOURCE_STATE_DEPTH_WRITE }, + }; + cmdResourceBarrier(cmd, 0, NULL, 2, barriers); + + // bind and clear the render target + LoadActionsDesc loadActions = {}; // render target clean command + loadActions.mLoadActionsColor[0] = LOAD_ACTION_CLEAR; + loadActions.mClearColorValues[0].r = 0.39f; + loadActions.mClearColorValues[0].g = 0.41f; + loadActions.mClearColorValues[0].b = 0.37f; + loadActions.mClearColorValues[0].a = 1.0f; + loadActions.mLoadActionDepth = LOAD_ACTION_CLEAR; + loadActions.mClearDepth.depth = 1.0f; + loadActions.mClearDepth.stencil = 0; + cmdBindRenderTargets(cmd, 1, &pRenderTarget, pDepthBuffer, &loadActions, NULL, NULL, -1, -1); + cmdSetViewport(cmd, 0.0f, 0.0f, (float)pRenderTarget->mDesc.mWidth, (float)pRenderTarget->mDesc.mHeight, 0.0f, 1.0f); + cmdSetScissor(cmd, 0, 0, pRenderTarget->mDesc.mWidth, pRenderTarget->mDesc.mHeight); + + //// draw plane + if (gUIData.mGeneralSettings.mDrawPlane) + { + cmdBeginDebugMarker(cmd, 1, 0, 1, "Draw Plane"); + cmdBindPipeline(cmd, pPlaneDrawPipeline); + cmdBindDescriptorSet(cmd, gFrameIndex, pDescriptorSetPlane); + cmdBindVertexBuffer(cmd, 1, &pPlaneVertexBuffer, NULL); + cmdDraw(cmd, 6, 0); + cmdEndDebugMarker(cmd); + } + + //// draw the skeleton of the rig + cmdBeginDebugMarker(cmd, 1, 0, 1, "Draw Skeletons"); + gSkeletonBatcher.Draw(cmd, gFrameIndex); + cmdEndDebugMarker(cmd); + + cmdBindVertexBuffer(cmd, 1, &pJointVertexBuffer, NULL); + cmdBindDescriptorSet(cmd, gFrameIndex, pDescriptorSetTarget); + cmdDrawInstanced(cmd, gNumberOfJointPoints / 6, 0, 1, 0); + + //// draw the UI + cmdBeginDebugMarker(cmd, 0, 1, 0, "Draw UI"); + loadActions = {}; + loadActions.mLoadActionsColor[0] = LOAD_ACTION_LOAD; + cmdBindRenderTargets(cmd, 1, &pRenderTarget, NULL, &loadActions, NULL, NULL, -1, -1); + gTimer.GetUSec(true); + + gVirtualJoystick.Draw(cmd, { 1.0f, 1.0f, 1.0f, 1.0f }); + + gAppUI.Gui(pStandaloneControlsGUIWindow); // adds the gui element to AppUI::ComponentsToUpdate list + gAppUI.DrawText( + cmd, float2(8, 15), eastl::string().sprintf("CPU %f ms", gTimer.GetUSecAverage() / 1000.0f).c_str(), &gFrameTimeDraw); + gAppUI.DrawText( + cmd, float2(8, 65), eastl::string().sprintf("Animation Update %f ms", gAnimationUpdateTimer.GetUSecAverage() / 1000.0f).c_str(), + &gFrameTimeDraw); + + gAppUI.DrawText( + cmd, float2(8, 40), eastl::string().sprintf("GPU %f ms", (float)pGpuProfiler->mCumulativeTime * 1000.0f).c_str(), + &gFrameTimeDraw); + + cmdDrawProfiler(); + gAppUI.Draw(cmd); + + cmdBindRenderTargets(cmd, 0, NULL, NULL, NULL, NULL, NULL, -1, -1); + cmdEndDebugMarker(cmd); + + // PRESENT THE GRPAHICS QUEUE + // + barriers[0] = { pRenderTarget->pTexture, RESOURCE_STATE_PRESENT }; + cmdResourceBarrier(cmd, 0, NULL, 1, barriers); + cmdEndGpuFrameProfile(cmd, pGpuProfiler); + endCmd(cmd); + + queueSubmit(pGraphicsQueue, 1, &cmd, pRenderCompleteFence, 1, &pImageAcquiredSemaphore, 1, &pRenderCompleteSemaphore); + queuePresent(pGraphicsQueue, pSwapChain, gFrameIndex, 1, &pRenderCompleteSemaphore); + flipProfiler(); + } + + const char* GetName() { return "26_InverseKinematic"; } + + bool addSwapChain() + { + SwapChainDesc swapChainDesc = {}; + swapChainDesc.mWindowHandle = pWindow->handle; + swapChainDesc.mPresentQueueCount = 1; + swapChainDesc.ppPresentQueues = &pGraphicsQueue; + swapChainDesc.mWidth = mSettings.mWidth; + swapChainDesc.mHeight = mSettings.mHeight; + swapChainDesc.mImageCount = gImageCount; + swapChainDesc.mSampleCount = SAMPLE_COUNT_1; + swapChainDesc.mColorFormat = getRecommendedSwapchainFormat(true); + swapChainDesc.mEnableVsync = false; + ::addSwapChain(pRenderer, &swapChainDesc, &pSwapChain); + + return pSwapChain != NULL; + } + + bool addDepthBuffer() + { + // Add depth buffer + RenderTargetDesc depthRT = {}; + depthRT.mArraySize = 1; + depthRT.mClearValue.depth = 1.0f; + depthRT.mClearValue.stencil = 0; + depthRT.mDepth = 1; + depthRT.mFormat = TinyImageFormat_D32_SFLOAT; + depthRT.mHeight = mSettings.mHeight; + depthRT.mSampleCount = SAMPLE_COUNT_1; + depthRT.mSampleQuality = 0; + depthRT.mWidth = mSettings.mWidth; + addRenderTarget(pRenderer, &depthRT, &pDepthBuffer); + + return pDepthBuffer != NULL; + } +}; + +DEFINE_APPLICATION_MAIN(AimIK) diff --git a/Examples_3/Unit_Tests/src/26_Audio/GPUCfg/gpu.cfg b/Examples_3/Unit_Tests/src/26_InverseKinematic/GPUCfg/gpu.cfg similarity index 100% rename from Examples_3/Unit_Tests/src/26_Audio/GPUCfg/gpu.cfg rename to Examples_3/Unit_Tests/src/26_InverseKinematic/GPUCfg/gpu.cfg diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/basic.frag b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/basic.frag new file mode 100644 index 0000000000..0de33b3909 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/basic.frag @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for simple shading with a point light +// for skeletons in Unit Test Animation + +struct VSOutput { + float4 Position : SV_POSITION; + float4 Color : COLOR; +}; + +float4 main(VSOutput input) : SV_TARGET +{ + return input.Color; +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/basic.vert b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/basic.vert new file mode 100644 index 0000000000..c951aa0104 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/basic.vert @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for simple shading with a point light +// for skeletons in Unit Tests Animation + +#define MAX_INSTANCES 815 + +cbuffer uniformBlock : register(b0, UPDATE_FREQ_PER_DRAW) +{ + float4x4 mvp; + + float4 color[MAX_INSTANCES]; + // Point Light Information + float4 lightPosition; + float4 lightColor; + + float4x4 toWorld[MAX_INSTANCES]; +}; + +struct VSInput +{ + float4 Position : POSITION; + float4 Normal : NORMAL; +}; + +struct VSOutput { + float4 Position : SV_POSITION; + float4 Color : COLOR; +}; + +VSOutput main(VSInput input, uint InstanceID : SV_InstanceID) +{ + VSOutput result; + float4x4 tempMat = mul(mvp, toWorld[InstanceID]); + result.Position = mul(tempMat, input.Position); + + float4 normal = normalize(mul(toWorld[InstanceID], float4(input.Normal.xyz, 0.0f))); // Assume uniform scaling + float4 pos = mul(toWorld[InstanceID], float4(input.Position.xyz, 1.0f)); + + float lightIntensity = 1.0f; + float quadraticCoeff = 1.2; + float ambientCoeff = 0.4; + + float3 lightDir = normalize(lightPosition.xyz - pos.xyz); + + float distance = length(lightDir); + float attenuation = 1.0 / (quadraticCoeff * distance * distance); + float intensity = lightIntensity * attenuation; + + float3 baseColor = color[InstanceID].xyz; + float3 blendedColor = mul(lightColor.xyz * baseColor, lightIntensity); + float3 diffuse = mul(blendedColor, max(dot(normal.xyz, lightDir), 0.0)); + float3 ambient = mul(baseColor, ambientCoeff); + result.Color = float4(diffuse + ambient, 1.0); + + return result; +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/plane.frag b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/plane.frag new file mode 100644 index 0000000000..63f57e5644 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/plane.frag @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for ground plane in Unit Tests Animation + +struct VSOutput { + float4 Position : SV_POSITION; + float2 TexCoord : TEXCOORD; +}; + +float4 main(VSOutput input) : SV_TARGET +{ + float tol = 0.0025f; + float res = 0.05f; + + float4 backgroundColor = float4(0.49f, 0.64f, 0.68f, 1.0f); // blue + float4 lineColor = float4(0.39f, 0.41f, 0.37f, 1.0f); // grey + float4 originColor = float4(0.0f, 0.0f, 0.0f, 1.0f); //black + + if ((abs(input.TexCoord.x - 0.5f) <= tol) && (abs(input.TexCoord.y - 0.5f) <= tol)) + { + return originColor; + } + else if ((fmod(input.TexCoord.x, res) >= (res - tol)) || (fmod(input.TexCoord.x, res) < tol) || (fmod(input.TexCoord.y, res) >= (res - tol)) || (fmod(input.TexCoord.y, res) < tol)) + { + return lineColor; + } + else + { + return backgroundColor; + } +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/plane.vert b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/plane.vert new file mode 100644 index 0000000000..7693b4f080 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/plane.vert @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for ground plane in Unit Tests Animation + +cbuffer uniformBlock : register(b0, UPDATE_FREQ_PER_DRAW) +{ + float4x4 mvp; + float4x4 toWorld; +}; + +struct VSInput +{ + float4 Position : POSITION; + float2 TexCoord : TEXCOORD0; +}; + +struct VSOutput { + float4 Position : SV_POSITION; + float2 TexCoord : TEXCOORD; +}; + +VSOutput main(VSInput input) +{ + VSOutput result; + float4x4 tempMat = mul(mvp, toWorld); + result.Position = mul(tempMat, input.Position); + + result.TexCoord = input.TexCoord; + + return result; +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/profile.frag b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/profile.frag new file mode 100644 index 0000000000..0c28e8065e --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/profile.frag @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + + +struct VSOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR; +}; + +float4 main(VSOutput In) : SV_Target +{ + return In.Color; +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/profile.vert b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/profile.vert new file mode 100644 index 0000000000..8366abd05d --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/D3D12/profile.vert @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +struct VSInput +{ + float2 Position : POSITION; + float4 Color : COLOR; +}; + +struct VSOutput { + float4 Position : SV_POSITION; + float4 Color : COLOR; +}; + +VSOutput main(VSInput input) +{ + VSOutput result; + result.Position = float4(input.Position.x, input.Position.y, 0.0f, 1.0f); + result.Color = input.Color; + return result; +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/basic.frag.metal b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/basic.frag.metal new file mode 100644 index 0000000000..272a241c91 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/basic.frag.metal @@ -0,0 +1,47 @@ +/* Write your header comments here */ +#include +#include +using namespace metal; + +inline float3x3 matrix_ctor(float4x4 m) { + return float3x3(m[0].xyz, m[1].xyz, m[2].xyz); +} +struct Fragment_Shader +{ +#define MAX_JOINTS 815 + + struct Uniforms_uniformBlock { + + float4x4 mvp; + float4x4 toWorld[MAX_JOINTS]; + float4 color[MAX_JOINTS]; + + float3 lightPosition; + float3 lightColor; + }; + struct VSOutput + { + float4 Position [[position]]; + float4 Color; + }; + + float4 main(VSOutput input) + { + return input.Color; + }; + + Fragment_Shader() {} +}; + +struct FSData { + constant Fragment_Shader::Uniforms_uniformBlock & uniformBlock; +}; + +fragment float4 stageMain(Fragment_Shader::VSOutput input [[stage_in]]) +{ + Fragment_Shader::VSOutput input0; + input0.Position = float4(input.Position.xyz, 1.0 / input.Position.w); + input0.Color = input.Color; + Fragment_Shader main; + return main.main(input0); +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/basic.vert.metal b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/basic.vert.metal new file mode 100644 index 0000000000..db63ba1fe9 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/basic.vert.metal @@ -0,0 +1,77 @@ +/* Write your header comments here */ +#include +#include +using namespace metal; + +inline float3x3 matrix_ctor(float4x4 m) { + return float3x3(m[0].xyz, m[1].xyz, m[2].xyz); +} +struct Vertex_Shader +{ +#define MAX_JOINTS 815 + + struct Uniforms_uniformBlock { + + float4x4 mvp; + float4 color[MAX_JOINTS]; + + float4 lightPosition; + float4 lightColor; + float4x4 toWorld[MAX_JOINTS]; + }; + constant Uniforms_uniformBlock & uniformBlock; + struct VSInput + { + float4 Position [[attribute(0)]]; + float4 Normal [[attribute(1)]]; + }; + + struct VSOutput + { + + float4 Position [[position]]; + float4 Color; + }; + + VSOutput main(VSInput input, uint InstanceID) + { + VSOutput result; + float4x4 tempMat = ((uniformBlock.mvp)*(uniformBlock.toWorld[InstanceID])); + result.Position = ((tempMat)*(input.Position)); + + float4 normal = normalize(((uniformBlock.toWorld[InstanceID])*(float4(input.Normal.xyz, 0.0)))); + float4 pos = ((uniformBlock.toWorld[InstanceID])*(float4(input.Position.xyz, 1.0))); + + float lightIntensity = 1.0; + float ambientCoeff = 0.4; + + float3 lightDir = (float3)(normalize(uniformBlock.lightPosition.xyz - pos.xyz)); + + float3 baseColor = uniformBlock.color[InstanceID].xyz; + float3 blendedColor = ((uniformBlock.lightColor.xyz * baseColor)*(lightIntensity)); + float3 diffuse = ((blendedColor)*(max(dot(normal.xyz, lightDir), 0.0))); + float3 ambient = ((baseColor)*(ambientCoeff)); + result.Color = float4(diffuse + ambient, 1.0); + + return result; + }; + + Vertex_Shader(constant Uniforms_uniformBlock & uniformBlock) : uniformBlock(uniformBlock) {} +}; + +struct VSData { + constant Vertex_Shader::Uniforms_uniformBlock & uniformBlock; +}; + +vertex Vertex_Shader::VSOutput stageMain(Vertex_Shader::VSInput input [[stage_in]], + uint InstanceID [[instance_id]], + constant VSData& vsData [[buffer(UPDATE_FREQ_PER_DRAW)]] +) { + Vertex_Shader::VSInput input0; + input0.Position = input.Position; + input0.Normal = input.Normal; + uint InstanceID0; + InstanceID0 = InstanceID; + Vertex_Shader main(vsData.uniformBlock); + return main.main(input0, InstanceID0); +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/plane.frag.metal b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/plane.frag.metal new file mode 100644 index 0000000000..e4912ce0ba --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/plane.frag.metal @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +using namespace metal; + +struct Fragment_Shader +{ + struct VSOutput + { + float4 Position [[position]]; + float2 TexCoord; + }; + + float4 main(VSOutput input) + { + float tol = 0.0025000000; + float res = 0.05; + float4 backgroundColor = float4(0.49f, 0.64f, 0.68f, 1.0f); + float4 lineColor = float4(0.39, 0.41, 0.37, 1.0); + float4 originColor = float4(0.0, 0.0, 0.0, 1.0); + if (((abs((input.TexCoord.x - 0.5)) <= tol) && (abs((input.TexCoord.y - 0.5)) <= tol))) + { + return originColor; + } + else if (((((fmod(input.TexCoord.x, res) >= (res - tol)) || (fmod(input.TexCoord.x, res) < tol)) || (fmod(input.TexCoord.y, res) >= (res - tol))) || (fmod(input.TexCoord.y, res) < tol))) + { + return lineColor; + } + else + { + return backgroundColor; + } + }; + + Fragment_Shader() {} +}; + + +fragment float4 stageMain(Fragment_Shader::VSOutput input [[stage_in]]) +{ + Fragment_Shader::VSOutput input0; + input0.Position = float4(input.Position.xyz, 1.0 / input.Position.w); + input0.TexCoord = input.TexCoord; + Fragment_Shader main; + return main.main(input0); +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/plane.vert.metal b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/plane.vert.metal new file mode 100644 index 0000000000..c2fa21809b --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/plane.vert.metal @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include +using namespace metal; + +struct Vertex_Shader +{ + struct Uniforms_uniformBlock + { + float4x4 mvp; + float4x4 toWorld; + }; + constant Uniforms_uniformBlock & uniformBlock; + struct VSInput + { + float4 Position [[attribute(0)]]; + float2 TexCoord [[attribute(1)]]; + }; + struct VSOutput + { + float4 Position [[position]]; + float2 TexCoord; + }; + VSOutput main(VSInput input) + { + VSOutput result; + float4x4 tempMat = ((uniformBlock.mvp)*(uniformBlock.toWorld)); + (result.Position = ((tempMat)*(input.Position))); + (result.TexCoord = input.TexCoord); + return result; + }; + + Vertex_Shader( +constant Uniforms_uniformBlock & uniformBlock) : +uniformBlock(uniformBlock) {} +}; + +struct VSData { + constant Vertex_Shader::Uniforms_uniformBlock & uniformBlock; +}; + +vertex Vertex_Shader::VSOutput stageMain( + Vertex_Shader::VSInput input [[stage_in]], + constant VSData& vsData [[buffer(UPDATE_FREQ_PER_DRAW)]] +) +{ + Vertex_Shader::VSInput input0; + input0.Position = input.Position; + input0.TexCoord = input.TexCoord; + Vertex_Shader main(vsData.uniformBlock); + return main.main(input0); +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/profile.frag.metal b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/profile.frag.metal new file mode 100644 index 0000000000..50c6195c3f --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/profile.frag.metal @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for simple shading with a point light +// for planets in Unit Test 01 - Transformations + +#include +using namespace metal; + +struct VSOutput { + float4 Position [[position]]; + float4 Color; +}; + +fragment float4 stageMain(VSOutput input [[stage_in]]) +{ + return input.Color; +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/profile.vert.metal b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/profile.vert.metal new file mode 100644 index 0000000000..99b142113f --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Metal/profile.vert.metal @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for simple shading with a point light +// for planets in Unit Test 01 - Transformations + +#include +using namespace metal; + +struct VSInput +{ + float2 Position [[attribute(0)]]; + float4 Color [[attribute(1)]]; +}; + +struct VSOutput { + float4 Position [[position]]; + float4 Color; +}; + +vertex VSOutput stageMain(VSInput input [[stage_in]]) +{ + VSOutput result; + result.Position = float4(input.Position.xy, 0.0f, 1.0f); + result.Color = input.Color; + return result; +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/basic.frag b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/basic.frag new file mode 100644 index 0000000000..73239e7eef --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/basic.frag @@ -0,0 +1,35 @@ +#version 450 core + +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + + +layout(location = 0) in vec4 Color; + +layout(location = 0) out vec4 outColor; + +void main () +{ + outColor = Color; +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/basic.vert b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/basic.vert new file mode 100644 index 0000000000..57ac6989eb --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/basic.vert @@ -0,0 +1,72 @@ +#version 450 core + +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + + +// Shader for simple shading with a point light +// for skeletons in Unit Tests Animation + +#define MAX_INSTANCES 815 + +layout(location = 0) in vec4 Position; +layout(location = 1) in vec4 Normal; + +layout(location = 0) out vec4 Color; + +layout (std140, UPDATE_FREQ_PER_DRAW, binding=0) uniform uniformBlock { + uniform mat4 mvp; + + uniform vec4 color[MAX_INSTANCES]; + // Point Light Information + uniform vec4 lightPosition; + uniform vec4 lightColor; + + uniform mat4 toWorld[MAX_INSTANCES]; +}; + +void main () +{ + mat4 tempMat = mvp * toWorld[gl_InstanceIndex]; + gl_Position = tempMat * vec4(Position.xyz, 1.0f); + + vec4 normal = normalize(toWorld[gl_InstanceIndex] * vec4(Normal.xyz, 0.0f)); + vec4 pos = toWorld[gl_InstanceIndex] * vec4(Position.xyz, 1.0f); + + float lightIntensity = 1.0f; + float quadraticCoeff = 1.2; + float ambientCoeff = 0.4; + + vec3 lightDir = normalize(lightPosition.xyz - pos.xyz); + + float distance = length(lightDir); + float attenuation = 1.0 / (quadraticCoeff * distance * distance); + float intensity = lightIntensity * attenuation; + + vec3 baseColor = color[gl_InstanceIndex].xyz; + vec3 blendedColor = lightColor.xyz * baseColor * lightIntensity; + vec3 diffuse = blendedColor * max(dot(normal.xyz, lightDir), 0.0); + vec3 ambient = baseColor * ambientCoeff; + Color = vec4(diffuse + ambient, 1.0); +} diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/plane.frag b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/plane.frag new file mode 100644 index 0000000000..1fd5aa02e5 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/plane.frag @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ +#version 450 core + +// Shader for ground plane in Unit Tests Animation + +layout(location = 0) in vec2 fragInput_TEXCOORD; +layout(location = 0) out vec4 rast_FragData0; + +struct VSOutput +{ + vec4 Position; + vec2 TexCoord; +}; + +vec4 HLSLmain(VSOutput input0) +{ + float tol = 0.0025000000; + float res = 0.05; + vec4 backgroundColor = vec4(0.49f, 0.64f, 0.68f, 1.0f); // blue + vec4 lineColor = vec4(0.39, 0.41, 0.37, 1.0); // grey + vec4 originColor = vec4(0.0, 0.0, 0.0, 1.0); // black + if(((abs((((input0).TexCoord).x - 0.5)) <= tol) && (abs((((input0).TexCoord).y - 0.5)) <= tol))) + { + return originColor; + } + else if (((((mod(((input0).TexCoord).x, res) >= (res - tol)) || (mod(((input0).TexCoord).x, res) < tol)) || (mod(((input0).TexCoord).y, res) >= (res - tol))) || (mod(((input0).TexCoord).y, res) < tol))) + { + return lineColor; + } + else + { + return backgroundColor; + } +} +void main() +{ + VSOutput input0; + input0.Position = vec4(gl_FragCoord.xyz, 1.0 / gl_FragCoord.w); + input0.TexCoord = fragInput_TEXCOORD; + vec4 result = HLSLmain(input0); + rast_FragData0 = result; +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/plane.vert b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/plane.vert new file mode 100644 index 0000000000..e67112d398 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/plane.vert @@ -0,0 +1,66 @@ +#version 450 core + +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +// Shader for ground plane in Unit Tests Animation + +layout(location = 0) in vec4 POSITION; +layout(location = 1) in vec2 TEXCOORD0; +layout(location = 0) out vec2 vertOutput_TEXCOORD; + +layout(UPDATE_FREQ_PER_DRAW, binding = 0) uniform uniformBlock +{ + mat4 mvp; + mat4 toWorld; +}; + +struct VSInput +{ + vec4 Position; + vec2 TexCoord; +}; +struct VSOutput +{ + vec4 Position; + vec2 TexCoord; +}; +VSOutput HLSLmain(VSInput input0) +{ + VSOutput result; + mat4 tempMat = ((mvp)*(toWorld)); + ((result).Position = ((tempMat)*((input0).Position))); + ((result).TexCoord = (input0).TexCoord); + return result; +} +void main() +{ + VSInput input0; + input0.Position = POSITION; + input0.TexCoord = TEXCOORD0; + VSOutput result = HLSLmain(input0); + gl_Position = result.Position; + vertOutput_TEXCOORD = result.TexCoord; +} + diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/profile.frag b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/profile.frag new file mode 100644 index 0000000000..e724751d33 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/profile.frag @@ -0,0 +1,35 @@ +#version 450 core + +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + + +layout(location = 0) in vec4 fColor; + +layout(location = 0) out vec4 outColor; + +void main () +{ + outColor = fColor; +} \ No newline at end of file diff --git a/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/profile.vert b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/profile.vert new file mode 100644 index 0000000000..7830d761b7 --- /dev/null +++ b/Examples_3/Unit_Tests/src/26_InverseKinematic/Shaders/Vulkan/profile.vert @@ -0,0 +1,36 @@ +#version 450 core + +/* + * Copyright (c) 2018-2019 Confetti Interactive Inc. + * + * This file is part of The-Forge + * (see https://github.com/ConfettiFX/The-Forge). + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +*/ + +layout(location = 0) in vec2 vPosition; +layout(location = 1) in vec4 vColor; + +layout(location = 0) out vec4 fColor; + +void main () +{ + gl_Position = vec4(vPosition, 0.0f, 1.0f); + fColor = vColor; +} diff --git a/Examples_3/Unit_Tests/src/26_Audio/26_Audio.cpp b/Examples_3/Unit_Tests/src/27_Audio/27_Audio.cpp similarity index 98% rename from Examples_3/Unit_Tests/src/26_Audio/26_Audio.cpp rename to Examples_3/Unit_Tests/src/27_Audio/27_Audio.cpp index cd8be4d7e2..cf3c088011 100644 --- a/Examples_3/Unit_Tests/src/26_Audio/26_Audio.cpp +++ b/Examples_3/Unit_Tests/src/27_Audio/27_Audio.cpp @@ -60,12 +60,12 @@ const char* pszBases[FSR_Count] = { - "../../../src/13_UserInterface/", // FSR_BinShaders - "../../../src/13_UserInterface/", // FSR_SrcShaders + "../../../src/27_Audio/", // FSR_BinShaders + "../../../src/27_Audio/", // FSR_SrcShaders "../../../UnitTestResources/", // FSR_Textures "../../../UnitTestResources/", // FSR_Meshes "../../../UnitTestResources/", // FSR_Builtin_Fonts - "../../../src/13_UserInterface/", // FSR_GpuConfig + "../../../src/27_Audio/", // FSR_GpuConfig "", // FSR_Animation "../../../UnitTestResources/", // FSR_Audio "", // FSR_OtherFiles @@ -443,7 +443,7 @@ class AudioUnitTest : public IApp queuePresent(pGraphicsQueue, pSwapChain, gFrameIndex, 1, &pRenderCompleteSemaphore); } - const char* GetName() { return "26_Audio"; } + const char* GetName() { return "27_Audio"; } bool addSwapChain() { diff --git a/Examples_3/Unit_Tests/src/27_Audio/GPUCfg/gpu.cfg b/Examples_3/Unit_Tests/src/27_Audio/GPUCfg/gpu.cfg new file mode 100644 index 0000000000..baf614bcb8 --- /dev/null +++ b/Examples_3/Unit_Tests/src/27_Audio/GPUCfg/gpu.cfg @@ -0,0 +1,637 @@ +#version: 0.1 +#Possible Classfications for Preset: Ultra; High; Medium; Medium-Low; Low; Office +#Sources: +#https://www.notebookcheck.net/Mobile-Graphics-Cards-Benchmark-List.844.0.html -> Classifies into Ultra; High; Medium; Low; Office +#https://github.com/GameTechDev/gpudetect/blob/master/IntelGfx.cfg +#https://github.com/GPUOpen-Tools/common-src-DeviceInfo/blob/master/DeviceInfoUtils.cpp + +#VendorId; DeviceId; Classification; Name ; Revision ID (Can be null) ; Codename (can be null) +#NVIDIA GPUs +0x10de; 0x0045; Low; NVIDIA GeForce 6800 GT +0x10de; 0x0040; Low; NVIDIA GeForce 6800 Ultra +0x10de; 0x0041; Low; NVIDIA GeForce 6800 +0x10de; 0x0042; Low; NVIDIA GeForce 6800 LE +0x10de; 0x0043; Low; NV40 +0x10de; 0x193; Low; NVIDIA GeForce 8800 GTS +0x10de; 0x0609; Low; NVIDIA GeForce 8800M GTS +0x10de; 0x622; Low; NVIDIA GeForce 9600 GT +0x10de; 0xa29; Low; NVIDIA GeForce GT 330M +0x10de; 0x0E22; Medium; NVIDIA GeForce GTX 460 +0x10de; 0x0E24; Medium; NVIDIA GeForce GTX 460 the other 460 with a different architecture +0x10de; 0x6ca; Medium; NVIDIA GeForce GTX 480M +0x10de; 0x6c0; Medium; NVIDIA GeForce GTX 480 +0x10de; 0x06D1; Low; NVIDIA Tesla C2050 +0x10de; 0x1080; Medium; NVIDIA GeForce GTX 580 +0x10de; 0x1211; Medium; NVIDIA GeForce GTX 580M +0x10de; 0x11E2; Medium; NVIDIA GeForce GTX 765M +0x10de; 0x119F; Medium; NVIDIA GeForce GTX 780M +0x10de; 0x1402; Medium; NVIDIA GeForce GTX 950 +0x10de; 0x1401; Medium; NVIDIA GeForce GTX 960 +0x10de; 0x13c2; High; NVIDIA GeForce GTX 970 +0x10de; 0x13c0; High; NVIDIA GeForce GTX 980 +0x10de; 0x17c8; Ultra; NVIDIA GeForce GTX 980 TI +0x10de; 0x1c81; Medium; NVIDIA GeForce GTX 1050 +0x10de; 0x1c82; Medium; NVIDIA GeForce GTX 1050 TI +0x10de; 0x1b84; Medium; NVIDIA GeForce GTX 1060 (3GB) +0x10de; 0x1c02; Medium; NVIDIA GeForce GTX 1060 (3GB; Ver 2) +0x10de; 0x1c03; Medium; NVIDIA GeForce GTX 1060 (6GB) +0x10de; 0x1b81; High; NVIDIA GeForce GTX 1070 +0x10de; 0x1b80; High; NVIDIA GeForce GTX 1080 +0x10de; 0x1b06; Ultra; NVIDIA GeForce GTX 1080 TI +0x10de; 0x100c; Ultra; NVIDIA GeForce GTX TITAN Black +0x10de; 0x1b00; Ultra; NVIDIA GeForce GTX TITAN X +0x10de; 0x1b30; Ultra; NVIDIA Quadro P6000 + + +#VendorId; DeviceId; Classification; Name ; Revision ID (Can be null) ; Codename (can be null) +#AMD GPUs +0x1002; 0x6798; Low; AMD Radeon R9 200 / HD 7900 Series ; 0x00; Tahiti +0x1002; 0x6799; Low; AMD Radeon HD 7900 Series ; 0x00; Tahiti +0x1002; 0x679A; Low; AMD Radeon HD 7900 Series ; 0x00; Tahiti +0x1002; 0x679B; Low; AMD Radeon HD 7900 Series ; 0x00; Tahiti +0x1002; 0x679E; Low; AMD Radeon HD 7800 Series ; 0x00; Tahiti +0x1002; 0x6780; Low; AMD FirePro W9000 ; 0x00; Tahiti +0x1002; 0x6784; Low; ATI FirePro V (FireGL V) Graphics Adapter ; 0x00; Tahiti +0x1002; 0x6788; Low; ATI FirePro V (FireGL V) Graphics Adapter ; 0x00; Tahiti +0x1002; 0x678A; Low; AMD FirePro W8000 ; 0x00; Tahiti +0x1002; 0x6818; Low; AMD Radeon HD 7800 Series ; 0x00; Pitcairn +0x1002; 0x6819; Low; AMD Radeon HD 7800 Series ; 0x00; Pitcairn +0x1002; 0x6808; Low; AMD FirePro W7000 ; 0x00; Pitcairn +0x1002; 0x6809; Low; ATI FirePro W5000 ; 0x00; Pitcairn +0x1002; 0x684C; Low; ATI FirePro V(FireGL V) Graphics Adapter ; 0x00; Pitcairn +0x1002; 0x6800; Low; AMD Radeon HD 7970M ; 0x00; Pitcairn +0x1002; 0x6801; Low; AMD Radeon(TM) HD8970M ; 0x00; Pitcairn +0x1002; 0x6806; Low; AMD Radeon (TM) R9 M290X ; 0x00; Pitcairn +0x1002; 0x6810; Low; AMD Radeon R9 200 Series ; 0x00; Pitcairn +0x1002; 0x6810; Low; AMD Radeon (TM) R9 370 Series ; 0x81; Pitcairn +0x1002; 0x6811; Low; AMD Radeon R9 200 Series ; 0x00; Pitcairn +0x1002; 0x6811; Low; AMD Radeon (TM) R7 370 Series ; 0x81; Pitcairn +0x1002; 0x6820; Low; AMD Radeon R9 M275X ; 0x00; Capeverde +0x1002; 0x6820; Low; AMD Radeon (TM) R9 M375 ; 0x81; Capeverde +0x1002; 0x6820; Low; AMD Radeon (TM) R9 M375X ; 0x83; Capeverde +0x1002; 0x6821; Low; AMD Radeon R9 M200X Series ; 0x00; Capeverde +0x1002; 0x6821; Low; AMD Radeon R9 (TM) M370X ; 0x83; Capeverde +0x1002; 0x6821; Low; AMD Radeon (TM) R7 M380 ; 0x87; Capeverde +0x1002; 0x6822; Low; AMD Radeon E8860 ; 0x00; Capeverde +0x1002; 0x6823; Low; AMD Radeon R9 M200X Series ; 0x00; Capeverde +0x1002; 0x6825; Low; AMD Radeon HD 7800M Series ; 0x00; Capeverde +0x1002; 0x6826; Low; AMD Radeon HD 7700M Series ; 0x00; Capeverde +0x1002; 0x6827; Low; AMD Radeon HD 7800M Series ; 0x00; Capeverde +0x1002; 0x682B; Low; AMD Radeon HD 8800M Series ; 0x00; Capeverde +0x1002; 0x682B; Low; AMD Radeon (TM) R9 M360 ; 0x87; Capeverde +0x1002; 0x682D; Low; AMD Radeon HD 7700M Series ; 0x00; Capeverde +0x1002; 0x682F; Low; AMD Radeon HD 7700M Series ; 0x00; Capeverde +0x1002; 0x6828; Low; AMD FirePro W600 ; 0x00; Capeverde +0x1002; 0x682C; Low; AMD FirePro W4100 ; 0x00; Capeverde +0x1002; 0x6830; Low; AMD Radeon 7800M Series ; 0x00; Capeverde +0x1002; 0x6831; Low; AMD Radeon 7700M Series ; 0x00; Capeverde +0x1002; 0x6835; Low; AMD Radeon R7 Series / HD 9000 Series ; 0x00; Capeverde +0x1002; 0x6837; Low; AMD Radeon HD 7700 Series ; 0x00; Capeverde +0x1002; 0x683D; Low; AMD Radeon HD 7700 Series ; 0x00; Capeverde +0x1002; 0x683F; Low; AMD Radeon HD 7700 Series ; 0x00; Capeverde + +#Amd-Oland +0x1002; 0x6608; Low; AMD FirePro W2100 ; 0x00; Oland +0x1002; 0x6610; Low; AMD Radeon R7 200 Series ; 0x00; Oland +0x1002; 0x6610; Low; AMD Radeon (TM) R7 350 ; 0x81; Oland +0x1002; 0x6610; Low; AMD Radeon (TM) R5 340 ; 0x83; Oland +0x1002; 0x6610; Low; AMD Radeon R7 200 Series ; 0x87; Oland +0x1002; 0x6611; Low; AMD Radeon R7 200 Series ; 0x00; Oland +0x1002; 0x6611; Low; AMD Radeon R7 200 Series ; 0x87; Oland +0x1002; 0x6613; Low; AMD Radeon R7 200 Series ; 0x00; Oland +0x1002; 0x6617; Low; AMD Radeon R7 240 Series ; 0x00; Oland +0x1002; 0x6617; Low; AMD Radeon R7 200 Series ; 0x87; Oland +0x1002; 0x6617; Low; AMD Radeon R7 240 Series ; 0xC7; Oland + +#Amd-Mars (Mobile Oland) +0x1002; 0x6600; Low; AMD Radeon HD 8600/8700M ; 0x00; Oland +0x1002; 0x6600; Low; AMD Radeon (TM) R7 M370 ; 0x81; Oland +0x1002; 0x6601; Low; AMD Radeon (TM) HD 8500M/8700M ; 0x00; Oland +0x1002; 0x6604; Low; AMD Radeon R7 M265 Series ; 0x00; Oland +0x1002; 0x6604; Low; AMD Radeon (TM) R7 M350 ; 0x81; Oland +0x1002; 0x6605; Low; AMD Radeon R7 M260 Series ; 0x00; Oland +0x1002; 0x6605; Low; AMD Radeon (TM) R7 M340 ; 0x81; Oland +0x1002; 0x6606; Low; AMD Radeon HD 8790M ; 0x00; Oland +0x1002; 0x6607; Low; AMD Radeon R5 M240 ; 0x00; Oland + +#Amd-Hainan +0x1002; 0x6660; Low; AMD Radeon HD 8600M Series ; 0x00; Hainan +0x1002; 0x6660; Low; AMD Radeon (TM) R5 M335 ; 0x81; Hainan +0x1002; 0x6660; Low; AMD Radeon (TM) R5 M330 ; 0x83; Hainan +0x1002; 0x6663; Low; AMD Radeon HD 8500M Series ; 0x00; Hainan +0x1002; 0x6663; Low; AMD Radeon (TM) R5 M320 ; 0x83; Hainan +0x1002; 0x6664; Low; AMD Radeon R5 M200 Series ; 0x00; Hainan +0x1002; 0x6665; Low; AMD Radeon R5 M230 Series ; 0x00; Hainan +0x1002; 0x6665; Low; AMD Radeon (TM) R5 M320 ; 0x83; Hainan +0x1002; 0x6665; Low; AMD Radeon R5 M435 ; 0xC3; Hainan +0x1002; 0x6666; Low; AMD Radeon R5 M200 Series ; 0x00; Hainan +0x1002; 0x6667; Low; AMD Radeon R5 M200 Series ; 0x00; Hainan +0x1002; 0x666F; Low; AMD Radeon HD 8500M ; 0x00; Hainan + +#Amd-Bonaire +0x1002; 0x6649; Low; AMD FirePro W5100 ; 0x00; Bonaire +0x1002; 0x6658; Low; AMD Radeon R7 200 Series ; 0x00; Bonaire +0x1002; 0x665C; Low; AMD Radeon HD 7700 Series ; 0x00; Bonaire +0x1002; 0x665D; Low; AMD Radeon R7 200 Series ; 0x00; Bonaire +0x1002; 0x665F; Low; AMD Radeon (TM) R7 360 Series ; 0x81; Bonaire +0x1002; 0x665F; Low; AMD Radeon (TM) R7 360 Series ; 0x81; Bonaire + +#Amd-Saturn (mobile Bonaire) +0x1002; 0x6640; Low; AMD Radeon HD 8950 ; 0x00; Bonaire +0x1002; 0x6640; Low; AMD Radeon (TM) R9 M380 ; 0x80; Bonaire +0x1002; 0x6646; Low; AMD Radeon R9 M280X ; 0x00; Bonaire +0x1002; 0x6646; Low; AMD Radeon (TM) R9 M385 ; 0x80; Bonaire +0x1002; 0x6647; Low; AMD Radeon R9 M200X Series ; 0x00; Bonaire +0x1002; 0x6647; Low; AMD Radeon (TM) R9 M380 ; 0x80; Bonaire + +#Amd-Hawaii +0x1002; 0x67A0; Low; AMD FirePro W9100 ; 0x00; Hawaii +0x1002; 0x67A1; Low; AMD FirePro W8100 ; 0x00; Hawaii +0x1002; 0x67B0; Low; AMD Radeon R9 200 Series ; 0x00; Hawaii +0x1002; 0x67B0; Low; AMD Radeon (TM) R9 390 Series ; 0x80; Hawaii +0x1002; 0x67B1; Low; AMD Radeon R9 200 Series ; 0x00; Hawaii +0x1002; 0x67B1; Low; AMD Radeon (TM) R9 390 Series ; 0x80; Hawaii +0x1002; 0x67B9; Low; AMD Radeon R9 200 Series ; 0x00; Hawaii + +#Amd-Kaveri -- will probably need multiple entries in g_deviceInfo for these +0x1002; 0x1309; Low; AMD Radeon(TM) R7 Graphics; 0x00; Spectre +0x1002; 0x130A; Low; AMD Radeon(TM) R6 Graphics; 0x00; Spectre +0x1002; 0x130C; Low; AMD Radeon(TM) R7 Graphics; 0x00; Spectre +0x1002; 0x130D; Low; AMD Radeon(TM) R6 Graphics; 0x00; Spectre +0x1002; 0x130E; Low; AMD Radeon(TM) R5 Graphics; 0x00; Spectre +0x1002; 0x130F; Low; AMD Radeon(TM) R7 Graphics; 0x00; Spectre +0x1002; 0x130F; Low; AMD Radeon(TM) R7 Graphics; 0xD4; Spectre +0x1002; 0x130F; Low; AMD Radeon(TM) R7 Graphics; 0xD5; Spectre +0x1002; 0x130F; Low; AMD Radeon(TM) R7 Graphics; 0xD6; Spectre +0x1002; 0x130F; Low; AMD Radeon(TM) R7 Graphics; 0xD7; Spectre +0x1002; 0x1313; Low; AMD Radeon(TM) R7 Graphics; 0x00; Spectre +0x1002; 0x1313; Low; AMD Radeon(TM) R7 Graphics; 0xD4; Spectre +0x1002; 0x1313; Low; AMD Radeon(TM) R7 Graphics; 0xD5; Spectre +0x1002; 0x1313; Low; AMD Radeon(TM) R7 Graphics; 0xD6; Spectre +0x1002; 0x1315; Low; AMD Radeon(TM) R5 Graphics; 0x00; Spectre +0x1002; 0x1315; Low; AMD Radeon(TM) R5 Graphics; 0xD4; Spectre +0x1002; 0x1315; Low; AMD Radeon(TM) R5 Graphics; 0xD5; Spectre +0x1002; 0x1315; Low; AMD Radeon(TM) R5 Graphics; 0xD6; Spectre +0x1002; 0x1315; Low; AMD Radeon(TM) R5 Graphics; 0xD7; Spectre +0x1002; 0x1318; Low; AMD Radeon(TM) R5 Graphics; 0x00; Spectre +0x1002; 0x131C; Low; AMD Radeon(TM) R7 Graphics; 0x00; Spectre +0x1002; 0x131D; Low; AMD Radeon(TM) R6 Graphics; 0x00; Spectre +0x1002; 0x130B; Low; AMD Radeon(TM) R4 Graphics; 0x00; Spectre +0x1002; 0x1316; Low; AMD Radeon(TM) R5 Graphics; 0x00; Spooky +0x1002; 0x131B; Low; AMD Radeon(TM) R4 Graphics; 0x00; Spectre + +#Amd-Kabini +0x1002; 0x9830; Low; AMD Radeon HD 8400 / R3 Series ; 0x00; Kalindi +0x1002; 0x9831; Low; AMD Radeon(TM) HD 8400E ; 0x00; Kalindi +0x1002; 0x9832; Low; AMD Radeon HD 8330 ; 0x00; Kalindi +0x1002; 0x9833; Low; AMD Radeon(TM) HD 8330E ; 0x00; Kalindi +0x1002; 0x9834; Low; AMD Radeon HD 8210 ; 0x00; Kalindi +0x1002; 0x9835; Low; AMD Radeon(TM) HD 8210E ; 0x00; Kalindi +0x1002; 0x9836; Low; AMD Radeon HD 8200 / R3 Series ; 0x00; Kalindi +0x1002; 0x9837; Low; AMD Radeon(TM) HD 8280E ; 0x00; Kalindi +0x1002; 0x9838; Low; AMD Radeon HD 8200 / R3 series ; 0x00; Kalindi + +#Amd-Temash +0x1002; 0x9839; Lo; AMD Radeon HD 8180; 0x00; Kalindi +0x1002; 0x983D; Lo; AMD Radeon HD 8250; 0x00; Kalindi + +#Amd-Beema +0x1002; 0x9850; Low; AMD Radeon(TM) R3 Graphics; 0x00; Mullins +0x1002; 0x9850; Low; AMD Radeon(TM) R3 Graphics; 0x03; Mullins +0x1002; 0x9850; Low; AMD Radeon(TM) R2 Graphics; 0x40; Mullins +0x1002; 0x9850; Low; AMD Radeon(TM) R3 Graphics; 0x45; Mullins +0x1002; 0x9851; Low; AMD Radeon(TM) R4 Graphics; 0x00; Mullins +0x1002; 0x9851; Low; AMD Radeon(TM) R5E Graphics; 0x01; Mullins +0x1002; 0x9851; Low; AMD Radeon(TM) R5 Graphics; 0x05; Mullins +0x1002; 0x9851; Low; AMD Radeon(TM) R5E Graphics; 0x06; Mullins +0x1002; 0x9851; Low; AMD Radeon(TM) R4 Graphics; 0x40; Mullins +0x1002; 0x9851; Low; AMD Radeon(TM) R5 Graphics; 0x45; Mullins +0x1002; 0x9852; Low; AMD Radeon(TM) R2 Graphics; 0x00; Mullins +0x1002; 0x9852; Low; AMD Radeon(TM) E1 Graphics; 0x40; Mullins +0x1002; 0x9853; Low; AMD Radeon(TM) R2 Graphics; 0x00; Mullins +0x1002; 0x9853; Low; AMD Radeon(TM) R4E Graphics; 0x01; Mullins +0x1002; 0x9853; Low; AMD Radeon(TM) R2 Graphics; 0x03; Mullins +0x1002; 0x9853; Low; AMD Radeon(TM) R1E Graphics; 0x05; Mullins +0x1002; 0x9853; Low; AMD Radeon(TM) R1E Graphics; 0x06; Mullins +0x1002; 0x9853; Low; AMD Radeon(TM) R2 Graphics; 0x40; Mullins + +#Amd-Mullins +0x1002; 0x9853; Low; AMD Radeon R1E Graphics; 0x07; Mullins +0x1002; 0x9853; Low; AMD Radeon R1E Graphics; 0x08; Mullins +0x1002; 0x9854; Low; AMD Radeon(TM) R3 Graphics; 0x00; Mullins +0x1002; 0x9854; Low; AMD Radeon(TM) R3E Graphics; 0x01; Mullins +0x1002; 0x9854; Low; AMD Radeon(TM) R3 Graphics; 0x02; Mullins +0x1002; 0x9854; Low; AMD Radeon(TM) R2 Graphics; 0x05; Mullins +0x1002; 0x9854; Low; AMD Radeon(TM) R4 Graphics; 0x06; Mullins +0x1002; 0x9854; Low; AMD Radeon(TM) R3 Graphics; 0x07; Mullins +0x1002; 0x9855; Low; AMD Radeon(TM) R6 Graphics; 0x02; Mullins +0x1002; 0x9855; Low; AMD Radeon(TM) R4 Graphics; 0x05; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R1E Graphics; 0x07; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R2 Graphics; 0x00; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R2E Graphics; 0x01; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R2 Graphics; 0x02; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R1E Graphics; 0x05; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R2 Graphics; 0x06; Mullins +0x1002; 0x9856; Low; AMD Radeon(TM) R1E Graphics; 0x07; Mullins +0x1002; 0x9856; Low; AMD Radeon R1E Graphics; 0x08; Mullins +0x1002; 0x9856; Low; AMD Radeon R1E Graphics; 0x13; Mullins + +#Amd-Iceland/Topaz +0x1002; 0x6900; Low; AMD Radeon R7 M260; 0x00; Iceland +0x1002; 0x6900; Low; AMD Radeon (TM) R7 M360; 0x81; Iceland +0x1002; 0x6900; Low; AMD Radeon (TM) R7 M340; 0x83; Iceland +0x1002; 0x6900; Low; AMD Radeon R5 M465 Series; 0xC1; Iceland +0x1002; 0x6900; Low; AMD Radeon R5 M445 Series; 0xC3; Iceland +0x1002; 0x6901; Low; AMD Radeon R5 M255; 0x00; Iceland +0x1002; 0x6902; Low; AMD Radeon Series; 0x00; Iceland +0x1002; 0x6907; Low; AMD Radeon R5 M255; 0x00; Iceland +0x1002; 0x6907; Low; AMD Radeon (TM) R5 M315; 0x87; Iceland + +#Amd-Tonga +0x1002; 0x6920; Low; AMD RADEON R9 M395X; 0x00; Tonga +0x1002; 0x6920; Low; AMD RADEON R9 M390X; 0x01; Tonga +0x1002; 0x6921; Low; AMD Radeon (TM) R9 M390X; 0x00; Tonga +0x1002; 0x6929; Low; AMD FirePro S7150; 0x00; Tonga +0x1002; 0x6929; Low; AMD FirePro S7100X; 0x01; Tonga +0x1002; 0x692B; Low; AMD FirePro W7100; 0x00; Tonga +0x1002; 0x692F; Low; AMD MxGPU; 0x00; Tonga +0x1002; 0x692F; Low; AMD MxGPU; 0x01; Tonga +0x1002; 0x6930; Low; AMD MxGPU; 0xF0; Tonga +0x1002; 0x6938; Low; AMD Radeon R9 200 Series; 0x00; Tonga +0x1002; 0x6938; Medium; AMD Radeon (TM) R9 380 Series; 0xF1; Tonga +0x1002; 0x6938; Low; AMD Radeon R9 200 Series; 0xF0; Tonga +0x1002; 0x6939; Low; AMD Radeon R9 200 Series; 0x00; Tonga +0x1002; 0x6939; Low; AMD Radeon R9 200 Series; 0xF0; Tonga +0x1002; 0x6939; Medium; AMD Radeon (TM) R9 380 Series; 0xF1; Tonga + +#Amd-Carrizo +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xC4; Carrizo +0x1002; 0x9874; Low; AMD Radeon R6 Graphics; 0xC5; Carrizo +0x1002; 0x9874; Low; AMD Radeon R6 Graphics; 0xC6; Carrizo +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0xC7; Carrizo +0x1002; 0x9874; Low; AMD Radeon R6 Graphics; 0x81; Carrizo +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0x84; Carrizo +0x1002; 0x9874; Low; AMD Radeon R6 Graphics; 0x85; Carrizo +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0x87; Carrizo +0x1002; 0x9874; Low; AMD Radeon R7E Graphics; 0x88; Carrizo +0x1002; 0x9874; Low; AMD Radeon R6E Graphics; 0x89; Carrizo +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xC8; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xC9; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0xCA; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0xCB; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xCC; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xCD; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0xCE; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xE1; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xE2; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xE3; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R7 Graphics; 0xE4; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0xE5; Bristol Ridge +0x1002; 0x9874; Low; AMD Radeon R5 Graphics; 0xE6; Bristol Ridge + +#Amd-Fiji +0x1002; 0x7300; Low; AMD Radeon (TM) Graphics Processor; 0x00; Fiji +0x1002; 0x7300; Low; AMD Radeon Graphics Processor; 0xC0; Fiji +0x1002; 0x7300; Low; AMD FirePro (TM) S9300 x2; 0xC1; Fiji +0x1002; 0x7300; Low; Radeon (TM) Pro Duo; 0xC9; Fiji +0x1002; 0x7300; High; AMD Radeon (TM) R9 Fury Series; 0xC8; Fiji +0x1002; 0x7300; High; AMD Radeon (TM) R9 Fury Series; 0xCA; Fiji +0x1002; 0x7300; High; AMD Radeon (TM) R9 Fury Series; 0xCB; Fiji +0x1002; 0x730F; Low; AMD MxGPU; 0xC9; Fiji + +#Amd-Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5E Graphics; 0x80; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4E Graphics; 0x81; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R2E Graphics; 0x83; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R2E Graphics; 0x84; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R1E Graphics; 0x86; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xC0; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5 Graphics; 0xC1; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xC2; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5 Graphics; 0xC4; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5 Graphics; 0xC6; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xC8; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xC9; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5 Graphics; 0xCA; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R2 Graphics; 0xD0; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R2 Graphics; 0xD1; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R2 Graphics; 0xD2; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R2 Graphics; 0xD4; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5 Graphics; 0xD9; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R5 Graphics; 0xDA; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R3 Graphics; 0xDB; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R3 Graphics; 0xE1; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R3 Graphics; 0xE2; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xE9; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xEA; Stoney +0x1002; 0x98E4; Low; AMD Radeon(TM) R4 Graphics; 0xEB; Stoney + +#Amd-Ellesmere +0x1002; 0x67C0; Low; Radeon (TM) Pro WX 7100 Graphics; 0x00; Ellesmere +0x1002; 0x67C0; Low; AMD Radeon (TM) E9550; 0x80; Ellesmere +0x1002; 0x67C1; Low; 67C1:00; 0x00; Ellesmere +0x1002; 0x67C2; Low; 67C2:00; 0x00; Ellesmere +0x1002; 0x67C2; Low; AMD Radeon (TM) Pro V7350x2; 0x01; Ellesmere +0x1002; 0x67C2; Low; AMD Radeon (TM) Pro V7300X; 0x02; Ellesmere +0x1002; 0x67C2; Low; 67C2:03; 0x03; Ellesmere +0x1002; 0x67C4; Low; AMD Radeon (TM) Pro WX 7100 Graphics; 0x00; Ellesmere +0x1002; 0x67C7; Low; Radeon (TM) Pro WX 5100 Graphics; 0x00; Ellesmere +0x1002; 0x67D0; Low; AMD Radeon (TM) Pro V7350x2; 0x01; Ellesmere +0x1002; 0x67D0; Low; AMD Radeon (TM) Pro V7300X; 0x02; Ellesmere +0x1002; 0x67DF; Low; 67DF:04; 0x04; Ellesmere +0x1002; 0x67DF; Low; 67DF:05; 0x05; Ellesmere +0x1002; 0x67DF; High; Radeon (TM) RX 480 Graphics; 0xC4; Ellesmere +0x1002; 0x67DF; High; Radeon (TM) RX 470 Graphics; 0xC5; Ellesmere +0x1002; 0x67DF; High; Radeon (TM) RX 480 Graphics; 0xC7; Ellesmere +0x1002; 0x67DF; High; Radeon (TM) RX 470 Graphics; 0xCF; Ellesmere +0x1002; 0x67DF; High; Radeon RX 470 Series; 0xFF; Ellesmere +0x1002; 0x67DF; Low; 67DF:C0; 0xC0; Ellesmere +0x1002; 0x67DF; High; Radeon RX 580 Series; 0xC1; Ellesmere +0x1002; 0x67DF; High; Radeon RX 570 Series; 0xC2; Ellesmere +0x1002; 0x67DF; High; Radeon RX 580 Series; 0xC3; Ellesmere +0x1002; 0x67DF; High; Radeon RX 570 Series; 0xC6; Ellesmere +0x1002; 0x67DF; Low; 67DF:CC; 0xCC; Ellesmere +0x1002; 0x67DF; Low; 67DF:CD; 0xCD; Ellesmere +0x1002; 0x67DF; Medium; Radeon(TM) RX 470 Graphics; 0xD7; Ellesmere +0x1002; 0x67DF; Medium; Radeon RX 470 Series; 0xE0; Ellesmere +0x1002; 0x67DF; Medium; Radeon RX Series; 0xE3; Ellesmere +0x1002; 0x67DF; High; Radeon RX 580 Series; 0xE7; Ellesmere +0x1002; 0x67DF; High; Radeon RX 570 Series; 0xEF; Ellesmere + +#Amd-Baffin +0x1002; 0x67E0; Low; Radeon (TM) Pro WX Series; 0x00; Baffin +0x1002; 0x67E3; Low; Radeon (TM) Pro WX 4100; 0x00; Baffin +0x1002; 0x67E8; Low; Radeon (TM) Pro WX Series; 0x00; Baffin +0x1002; 0x67E8; Low; Radeon (TM) Pro WX Series; 0x01; Baffin +0x1002; 0x67E8; Low; AMD Radeon (TM) E9260; 0x80; Baffin +0x1002; 0x67EB; Low; Radeon (TM) Pro V5300X; 0x00; Baffin +0x1002; 0x67EF; Medium; AMD Radeon Pro 460; 0xC0; Baffin +0x1002; 0x67EF; Medium; Radeon(TM) RX 460 Graphics; 0xC1; Baffin +0x1002; 0x67EF; Medium; Radeon(TM) RX 460 Graphics; 0xC5; Baffin +0x1002; 0x67EF; Medium; AMD Radeon Pro 455; 0xC7; Baffin +0x1002; 0x67EF; Medium; Radeon(TM) RX 460 Graphics; 0xCF; Baffin +0x1002; 0x67EF; Medium; AMD Radeon Pro 450; 0xEF; Baffin +0x1002; 0x67FF; Medium; AMD Radeon Pro 465; 0xC0; Baffin +0x1002; 0x67FF; Low; Radeon RX 560 Series; 0xC1; Baffin +0x1002; 0x67EF; Low; Radeon Pro Series; 0xC2; Baffin +0x1002; 0x67EF; Low; 67EF:C3; 0xC3; Baffin +0x1002; 0x67EF; Low; 67EF:E2; 0xE2; Baffin +0x1002; 0x67EF; Low; Radeon Pro Series; 0xE3; Baffin +0x1002; 0x67EF; Medium; Radeon RX 560 Series; 0xE5; Baffin +0x1002; 0x67EF; Medium; Radeon RX 560 Series; 0xE7; Baffin +0x1002; 0x67EF; Medium; Radeon RX 560 Series; 0xE0; Baffin +0x1002; 0x67EF; Medium; Radeon(TM) RX 460 Graphics; 0xFF; Baffin +0x1002; 0x67FF; Low; 67FF:08; 0x08; Baffin +0x1002; 0x67FF; Medium; Radeon RX 560 Series; 0xCF; Baffin +0x1002; 0x67FF; Medium; Radeon RX 560 Series; 0xEF; Baffin +0x1002; 0x67FF; Medium; Radeon RX 550 Series; 0xFF; Baffin + +#Amd-GFX8_0_4 +0x1002; 0x6980; Low; Radeon Pro WX 3100; 0x00; gfx804 +0x1002; 0x6981; Low; 6981:C0; 0xC0; gfx804 +0x1002; 0x6985; Low; AMD Radeon Pro WX 3100; 0x00; gfx804 +0x1002; 0x6986; Low; AMD Radeon Pro WX 2100; 0x00; gfx804 +0x1002; 0x6987; Low; AMD Embedded Radeon E9171; 0x80; gfx804 +0x1002; 0x6995; Low; AMD Radeon Pro WX 2100; 0x00; gfx804 +0x1002; 0x6997; Low; Radeon Pro WX 2100; 0x00; gfx804 +0x1002; 0x699F; Low; AMD Embedded Radeon E9170 Series; 0x81; gfx804 +0x1002; 0x699F; Medium; Radeon 500 Series; 0xC0; gfx804 +0x1002; 0x699F; Medium; Radeon 540 Series; 0xC1; gfx804 +0x1002; 0x699F; Medium; Radeon 500 Series; 0xC3; gfx804 +0x1002; 0x699F; Low; 699F:C5; 0xC5; gfx804 +0x1002; 0x699F; Low; Radeon 550 Series; 0xC7; gfx804 +0x1002; 0x699F; Low; 699F:CF; 0xCF; gfx804 + +#Amd-VegaM +0x1002; 0x694C; High; Radeon RX Vega M GH Graphics; 0xC0; gfx804 +0x1002; 0x694E; Medium; Radeon RX Vega M GL Graphics; 0xC0; gfx804 +0x1002; 0x694F; Low; 694F:C0; 0xC0; gfx804 + +#Amd-GFX9_0_0 +0x1002; 0x6860; Low; Radeon Instinct MI25; 0x00; gfx900 +0x1002; 0x6860; Low; 6860:01; 0x01; gfx900 +0x1002; 0x6860; Low; Radeon Instinct MI25; 0x02; gfx900 +0x1002; 0x6860; Low; 6860:03; 0x03; gfx900 +0x1002; 0x6860; Low; 6860:04; 0x04; gfx900 +0x1002; 0x6860; Low; 6860:C0; 0xC0; gfx900 +0x1002; 0x6861; Low; Radeon (TM) Pro WX 9100; 0x00; gfx900 +0x1002; 0x6862; Low; Radeon Pro SSG; 0x00; gfx900 +0x1002; 0x6863; Low; Radeon Vega Frontier Edition; 0x00; gfx900 +0x1002; 0x6864; Low; 6864:00; 0x00; gfx900 +0x1002; 0x6864; Low; 6864:03; 0x03; gfx900 +0x1002; 0x6864; Low; 6864:04; 0x04; gfx900 +0x1002; 0x6867; Low; 6867:00; 0x00; gfx900 +0x1002; 0x6868; Low; 6868:00; 0x00; gfx900 +0x1002; 0x6869; Low; 6869:00; 0x00; gfx900 +0x1002; 0x686A; Low; 686A:00; 0x00; gfx900 +0x1002; 0x686B; Low; 686B:00; 0x00; gfx900 +0x1002; 0x686C; Low; Radeon Instinct MI25 MxGPU; 0x00; gfx900 +0x1002; 0x686C; Low; 686C:01; 0x01; gfx900 +0x1002; 0x686C; Low; Radeon Instinct MI25 MxGPU; 0x02; gfx900 +0x1002; 0x686C; Low; 686C:03; 0x03; gfx900 +0x1002; 0x686C; Low; 686C:04; 0x04; gfx900 +0x1002; 0x686C; Low; 686C:C1; 0xC1; gfx900 +0x1002; 0x687F; Low; 687F:01; 0x01; gfx900 +0x1002; 0x687F; High; Radeon RX Vega; 0xC0; gfx900 +0x1002; 0x687F; High; Radeon RX Vega; 0xC1; gfx900 +0x1002; 0x687F; High; Radeon RX Vega; 0xC3; gfx900 +0x1002; 0x687F; Low; 687F:C4; 0xC4; gfx900 +0x1002; 0x687F; High; Radeon RX Vega; 0xC7; gfx900 + +#Amd-GFX9_0_2 +#To Do : Add revision for gpu's below as they all have same Device ID +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0x00; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0x86; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0x87; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xC1; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xC6; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xC7; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xC9; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xCD; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xD2; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xD3; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xD4; gfx902 +0x1002; 0x15DD; Low; AMD 15DD Graphics; 0xD6; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0x85; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0xC5; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0xCB; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0xCE; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0xD8; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0xE1; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 3 Graphics; 0xE2; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 6 Graphics; 0x84; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 6 Graphics; 0xD9; gfx902 +0x1002; 0x15DD; Low; AMD Radeon(TM) Vega 6 Graphics; 0xCC; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0x82; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0x83; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0x88; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xD1; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xD5; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xD7; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xC2; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xC4; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xC8; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) Vega 8 Graphics; 0xCA; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) RX Vega 10 Graphics; 0xC3; gfx902 +0x1002; 0x15DD; Medium; AMD Radeon(TM) RX Vega 10 Graphics; 0xD0; gfx902 + + +# VendorId; DeviceId; Classification; Name ; Revision ID (Can be null) ; Codename (can be null) +# INTEL GPUs +# Other +0x8086; 0x2982; Office; Intel(R) G35 Express Chipset Family; +0x8086; 0x2983; Office; Intel(R) G35 Express Chipset Family; +0x8086; 0x2A02; Office; Mobile Intel(R) 965 Express Chipset Family; +0x8086; 0x2A03; Office; Mobile Intel(R) 965 Express Chipset Family; +0x8086; 0x2A12; Office; Mobile Intel(R) 965 Express Chipset Family; +0x8086; 0x2A13; Office; Mobile Intel(R) 965 Express Chipset Family; +0x8086; 0x2A42; Office; Mobile Intel(R) 4 Series Express Chipset Family; +0x8086; 0x2A43; Office; Mobile Intel(R) 4 Series Express Chipset Family; +0x8086; 0x2E02; Office; Intel(R) 4 Series Express Chipset; +0x8086; 0x2E03; Office; Intel(R) 4 Series Express Chipset; +0x8086; 0x2E22; Office; Intel(R) G45/G43 Express Chipset; +0x8086; 0x2E23; Office; Intel(R) G45/G43 Express Chipset; +0x8086; 0x2E12; Office; Intel(R) Q45/Q43 Express Chipset; +0x8086; 0x2E13; Office; Intel(R) Q45/Q43 Express Chipset; +0x8086; 0x2E32; Office; Intel(R) G41 Express Chipset; +0x8086; 0x2E33; Office; Intel(R) G41 Express Chipset; +0x8086; 0x2E42; Office; Intel(R) B43 Express Chipset; +0x8086; 0x2E43; Office; Intel(R) B43 Express Chipset; +0x8086; 0x2E92; Office; Intel(R) B43 Express Chipset; +0x8086; 0x2E93; Office; Intel(R) B43 Express Chipset; +0x8086; 0x0046; Office; Intel(R) HD Graphics - Core i3/i5/i7 Mobile Processors; +0x8086; 0x0042; Office; Intel(R) HD Graphics - Core i3/i5 + Pentium G9650 Processors; + +# Sandybridge +0x8086; 0x0102; Office; Intel(R) HD Graphics 2000; +0x8086; 0x0106; Office; Intel(R) HD Graphics 2000; +0x8086; 0x0112; Office; Intel(R) HD Graphics 3000; +0x8086; 0x0116; Office; Intel(R) HD Graphics 3000; +0x8086; 0x0122; Office; Intel(R) HD Graphics 3000; +0x8086; 0x0126; Office; Intel(R) HD Graphics 3000; +0x8086; 0x010A; Office; Intel(R) HD Graphics; + +# Ivybridge +0x8086; 0x0152; Office; Intel(R) HD Graphics 2500; +0x8086; 0x0156; Office; Intel(R) HD Graphics 2500; +0x8086; 0x015A; Office; Intel(R) HD Graphics 2500; +0x8086; 0x0162; Office; Intel(R) HD Graphics 4000; +0x8086; 0x0166; Office; Intel(R) HD Graphics 4000; +0x8086; 0x016A; Office; Intel(R) HD Graphics 4000; + +# Haswell +0x8086; 0x0402; Office; Intel(R) HD Graphics; +0x8086; 0x0412; Office; Intel(R) HD Graphics 4600; +0x8086; 0x0422; Office; Intel(R) HD Graphics 5000; +0x8086; 0x0406; Office; Intel(R) HD Graphics; +0x8086; 0x0416; Office; Intel(R) HD Graphics 4600; +0x8086; 0x0426; Office; Intel(R) HD Graphics 5000; +0x8086; 0x040A; Office; Intel(R) HD Graphics; +0x8086; 0x041A; Office; Intel(R) HD Graphics P4600/P4700; +0x8086; 0x042A; Office; Intel(R) HD Graphics 5000; +0x8086; 0x040B; Office; Intel(R) HD Graphics; +0x8086; 0x041B; Office; Intel(R) HD Graphics; +0x8086; 0x042B; Office; Intel(R) HD Graphics; +0x8086; 0x040E; Office; Intel(R) HD Graphics; +0x8086; 0x041E; Office; Intel(R) HD Graphics; +0x8086; 0x042E; Office; Intel(R) HD Graphics; +0x8086; 0x0A02; Office; Intel(R) HD Graphics; +0x8086; 0x0A12; Office; Intel(R) HD Graphics; +0x8086; 0x0A22; Office; Intel(R) Iris(TM) Graphics 5100; +0x8086; 0x0A06; Office; Intel(R) HD Graphics; +0x8086; 0x0A16; Office; Intel(R) HD Graphics 4400; +0x8086; 0x0A26; Office; Intel(R) HD Graphics 5000; +0x8086; 0x0A0A; Office; Intel(R) HD Graphics; +0x8086; 0x0A1A; Office; Intel(R) HD Graphics; +0x8086; 0x0A2A; Office; Intel(R) Iris(TM) Graphics 5100; +0x8086; 0x0A0B; Office; Intel(R) HD Graphics; +0x8086; 0x0A1B; Office; Intel(R) HD Graphics; +0x8086; 0x0A2B; Office; Intel(R) Iris(TM) Graphics 5100; +0x8086; 0x0A0E; Office; Intel(R) HD Graphics; +0x8086; 0x0A1E; Office; Intel(R) HD Graphics 4200; +0x8086; 0x0A2E; Office; Intel(R) Iris(TM) Graphics 5100; +0x8086; 0x0D02; Office; Intel(R) HD Graphics; +0x8086; 0x0D12; Office; Intel(R) HD Graphics 4600; +0x8086; 0x0D22; Office; Intel(R) Iris(TM) Pro Graphics 5200; +0x8086; 0x0D06; Office; Intel(R) HD Graphics; +0x8086; 0x0D16; Office; Intel(R) HD Graphics 4600; +0x8086; 0x0D26; Office; Intel(R) Iris(TM) Pro Graphics 5200; +0x8086; 0x0D0A; Office; Intel(R) HD Graphics; +0x8086; 0x0D1A; Office; Intel(R) HD Graphics; +0x8086; 0x0D2A; Office; Intel(R) Iris(TM) Pro Graphics 5200; +0x8086; 0x0D0B; Office; Intel(R) HD Graphics; +0x8086; 0x0D1B; Office; Intel(R) HD Graphics; +0x8086; 0x0D2B; Office; Intel(R) Iris(TM) Pro Graphics 5200; +0x8086; 0x0D0E; Office; Intel(R) HD Graphics; +0x8086; 0x0D1E; Office; Intel(R) HD Graphics; +0x8086; 0x0D2E; Office; Intel(R) Iris(TM) Pro Graphics 5200; + +# Broadwell +0x8086; 0x1602; Low; Intel(R) HD Graphics; +0x8086; 0x1606; Low; Intel(R) HD Graphics; +0x8086; 0x160B; Low; Intel(R) HD Graphics; +0x8086; 0x160A; Low; Intel(R) HD Graphics; +0x8086; 0x160D; Low; Intel(R) HD Graphics; +0x8086; 0x160E; Low; Intel(R) HD Graphics; +0x8086; 0x1612; Low; Intel(R) HD Graphics 5600; +0x8086; 0x1616; Low; Intel(R) HD Graphics 5500; +0x8086; 0x161B; Low; Intel(R) HD Graphics; +0x8086; 0x161A; Low; Intel(R) HD Graphics; +0x8086; 0x161D; Low; Intel(R) HD Graphics; +0x8086; 0x161E; Low; Intel(R) HD Graphics 5300; +0x8086; 0x1622; Low; Intel(R) Iris(TM) Pro Graphics 6200; +0x8086; 0x1626; Low; Intel(R) HD Graphics 6000; +0x8086; 0x162B; Low; Intel(R) Iris(TM) Graphics 6100; +0x8086; 0x162A; Low; Intel(R) Iris(TM) Pro Graphics P6300; +0x8086; 0x162D; Low; Intel(R) HD Graphics; +0x8086; 0x162E; Low; Intel(R) HD Graphics; +0x8086; 0x1632; Low; Intel(R) HD Graphics; +0x8086; 0x1636; Low; Intel(R) HD Graphics; +0x8086; 0x163B; Low; Intel(R) HD Graphics; +0x8086; 0x163A; Low; Intel(R) HD Graphics; +0x8086; 0x163D; Low; Intel(R) HD Graphics; +0x8086; 0x163E; Low; Intel(R) HD Graphics; + +; Skylake +0x8086; 0x1902; Low; Intel(R) HD Graphics 510; +0x8086; 0x1906; Low; Intel(R) HD Graphics 510; +0x8086; 0x190A; Low; Intel(R) HD Graphics; +0x8086; 0x190B; Low; Intel(R) HD Graphics; +0x8086; 0x190E; Low; Intel(R) HD Graphics; +0x8086; 0x1912; Low; Intel(R) HD Graphics 530; +0x8086; 0x1916; Low; Intel(R) HD Graphics 520; +0x8086; 0x191A; Low; Intel(R) HD Graphics; +0x8086; 0x191B; Low; Intel(R) HD Graphics 530; +0x8086; 0x191D; Low; Intel(R) HD Graphics P530; +0x8086; 0x191E; Low; Intel(R) HD Graphics 515; +0x8086; 0x1921; Low; Intel(R) HD Graphics; +0x8086; 0x1926; Low; Intel(R) Iris Graphics 540; +0x8086; 0x1927; Low; Intel(R) Iris Graphics 540; +0x8086; 0x192A; Low; Intel(R) HD Graphics; +0x8086; 0x192B; Low; Intel(R) HD Graphics; +0x8086; 0x193B; Medium; Intel(R) Iris Pro Graphics 580; +0x8086; 0x193D; Medium; Intel(R) Iris Pro Graphics P580; + +; CherryTrail and Braswell +0x8086; 0x22B0; Low; Intel(R) HD Graphics; +0x8086; 0x22B1; Low; Intel(R) HD Graphics; +0x8086; 0x22B2; Low; Intel(R) HD Graphics; +0x8086; 0x22B3; Low; Intel(R) HD Graphics; + +; Kabylake +0x8086; 0x5902; Low; Intel(R) HD Graphics 610; +0x8086; 0x5906; Low; Intel(R) HD Graphics 610; +0x8086; 0x590B; Low; Intel(R) HD Graphics P610; +0x8086; 0x5912; Low; Intel(R) HD Graphics 630; +0x8086; 0x5916; Low; Intel(R) HD Graphics 620; +0x8086; 0x5917; Low; Intel(R) UHD Graphics 620; +0x8086; 0x591B; Low; Intel(R) HD Graphics 630; +0x8086; 0x591D; Low; Intel(R) HD Graphics P630; +0x8086; 0x591E; Low; Intel(R) HD Graphics 615; +0x8086; 0x5921; Low; Intel(R) HD Graphics 620; +0x8086; 0x5926; Low; Intel(R) Iris Plus Graphics 640; +0x8086; 0x5927; Medium; Intel(R) Iris Plus Graphics 650; + +; Coffeelake +0x8086; 0x3E91; Low; Intel(R) UHD Graphics; +0x8086; 0x3E92; Low; Intel(R) UHD Graphics; diff --git a/Middleware_3/Animation/AnimatedObject.cpp b/Middleware_3/Animation/AnimatedObject.cpp index 8abc15d3ad..4c8198cdc8 100644 --- a/Middleware_3/Animation/AnimatedObject.cpp +++ b/Middleware_3/Animation/AnimatedObject.cpp @@ -23,6 +23,23 @@ */ #include "AnimatedObject.h" +#include "../../Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_aim_job.h" +#include "../../Common_3/ThirdParty/OpenSource/ozz-animation/include/ozz/animation/runtime/ik_two_bone_job.h" + +namespace { +void MultiplySoATransformQuaternion(int _index, const Quat& _quat, ozz::Range& _transforms) +{ + SoaTransform& soa_transform_ref = _transforms[_index / 4]; + Vector4 aos_quats[4]; + + transpose4x4(&soa_transform_ref.rotation.x, aos_quats); + + Vector4& aos_quat_ref = aos_quats[_index & 3]; + aos_quat_ref = Vector4((Quat(aos_quat_ref) * _quat).get128()); + + transpose4x4(aos_quats, &soa_transform_ref.rotation.x); +} +} // namespace void AnimatedObject::Initialize(Rig* rig, Animation* animation) { @@ -62,6 +79,108 @@ bool AnimatedObject::Update(float dt) return true; } +bool AnimatedObject::AimIK(AimIKDesc* params, Point3 target) +{ + ozz::Range models = mRig->GetJointModelMats(); + + ozz::animation::IKAimJob ikJob; + ikJob.pole_vector = params->mPoleVector; + ikJob.twist_angle = params->mTwistAngle; + ikJob.target = target; + ikJob.reached = ¶ms->mReached; + + Quat correction; + ikJob.joint_correction = &correction; + + int previous_joint = ozz::animation::Skeleton::kNoParentIndex; + for (int i = 0, joint = params->mJointChain[0]; i < params->mJointChainLength; + ++i, previous_joint = joint, joint = params->mJointChain[i]) + { + ikJob.joint = &models[joint]; + ikJob.up = params->mJointUpVectors[i]; + + const bool last = i == params->mJointChainLength - 1; + ikJob.weight = last ? 1.f : params->mJointWeight; + + if (i == 0) + { + ikJob.offset = params->mOffset; + ikJob.forward = params->mForward; + } + else + { + const Vector3 corrected_forward_ms((models[previous_joint] * rotate(correction, ikJob.forward)).getXYZ()); + const Point3 corrected_offset_ms((models[previous_joint] * Point3(rotate(correction, ikJob.offset))).getXYZ()); + + Matrix4 inv_joint = inverse(models[joint]); + ikJob.forward = (inv_joint * corrected_forward_ms).getXYZ(); + ikJob.offset = (inv_joint * corrected_offset_ms).getXYZ(); + } + + if (!ikJob.Run()) + { + return false; + } + + MultiplySoATransformQuaternion(joint, correction, mLocalTrans); + } + + ozz::animation::LocalToModelJob ltmJob; + ltmJob.skeleton = mRig->GetSkeleton(); + ltmJob.input = mLocalTrans; + ltmJob.output = mRig->GetJointModelMats(); + + if (!ltmJob.Run()) + return false; + + return true; +} + +bool AnimatedObject::TwoBonesIK(TwoBonesIKDesc* params, Point3 target) +{ + ozz::animation::IKTwoBoneJob ik_job; + + ik_job.target = target; + ik_job.pole_vector = params->mPoleVector; + ik_job.mid_axis = params->mMidAxis; + + ik_job.weight = params->mWeight; + ik_job.soften = params->mSoften; + ik_job.twist_angle = params->mTwistAngle; + + ozz::Range models = mRig->GetJointModelMats(); + + ik_job.start_joint = &models[params->mJointChain[0]]; + ik_job.mid_joint = &models[params->mJointChain[1]]; + ik_job.end_joint = &models[params->mJointChain[2]]; + + // Outputs + Quat start_correction; + ik_job.start_joint_correction = &start_correction; + Quat mid_correction; + ik_job.mid_joint_correction = &mid_correction; + ik_job.reached = ¶ms->mReached; + + if (!ik_job.Run()) + { + return false; + } + + MultiplySoATransformQuaternion(params->mJointChain[0], start_correction, mLocalTrans); + MultiplySoATransformQuaternion(params->mJointChain[1], mid_correction, mLocalTrans); + + ozz::animation::LocalToModelJob ltmJob; + ltmJob.skeleton = mRig->GetSkeleton(); + ltmJob.input = mLocalTrans; + ltmJob.output = mRig->GetJointModelMats(); + + // Runs ltm job. + if (!ltmJob.Run()) + return false; + + return true; +} + void AnimatedObject::PoseRigInBind() { // Setup local-to-model conversion job. diff --git a/Middleware_3/Animation/AnimatedObject.h b/Middleware_3/Animation/AnimatedObject.h index 42731f51af..f557c579b3 100644 --- a/Middleware_3/Animation/AnimatedObject.h +++ b/Middleware_3/Animation/AnimatedObject.h @@ -32,6 +32,56 @@ #include "Rig.h" #include "Animation.h" +struct AimIKDesc +{ + // Joint forward axis, in joint local-space, to be aimed at target position. + Vector3 mForward; + // Offset position from the joint in local-space, that will aim at target. + Vector3 mOffset; + // Pole vector, in model-space. The pole vector defines the direction + // the up should point to. + Vector3 mPoleVector; + // Twist_angle rotates joint around the target vector. + float mTwistAngle; + // Weight given to the IK correction clamped in range [0,1]. Applied to each joint in chain. + float mJointWeight; + // Chain Length + int mJointChainLength; + // Array of joint indexes. + const int* mJointChain; + // Array of joint up axises, in joint local-space, used to keep the joint oriented in the + // same direction as the pole vector. + const Vector3* mJointUpVectors; + // Optional boolean output value, set to true if target can be reached with IK + // computations. + bool mReached; +}; + +struct TwoBonesIKDesc +{ + // Pole vector, in model-space. The pole vector defines the direction the + // middle joint should point to, allowing to control IK chain orientation. + Vector3 mPoleVector; + // Normalized middle joint rotation axis, in middle joint local-space. + Vector3 mMidAxis; + // Weight given to the IK correction clamped in range [0,1]. + float mWeight; + // Soften ratio allows the chain to gradually fall behind the target + // position. This prevents the joint chain from snapping into the final + // position, softening the final degrees before the joint chain becomes flat. + // This ratio represents the distance to the end, from which softening is + // starting. + float mSoften; + // Twist_angle rotates IK chain around the vector define by start-to-target + // vector. + float mTwistAngle; + // Array of joint indexes. + int mJointChain[3]; + // Optional boolean output value, set to true if target can be reached with IK + // computations. + bool mReached; +}; + // Responsible for coordinating the posing of a Rig by an Animation class AnimatedObject { @@ -45,6 +95,11 @@ class AnimatedObject // To be called every frame of the main application, handles sampling and updating the current animation bool Update(float dt); + bool AimIK(AimIKDesc* params, Point3 target); + + // Apply two bone inverse kinematic + bool TwoBonesIK(TwoBonesIKDesc* params, Point3 target); + // Update mRigs world matricies inline void PoseRig() { mRig->Pose(mRootTransform); }; diff --git a/Middleware_3/Animation/Rig.cpp b/Middleware_3/Animation/Rig.cpp index c82d985fc4..227f51e1dd 100644 --- a/Middleware_3/Animation/Rig.cpp +++ b/Middleware_3/Animation/Rig.cpp @@ -154,8 +154,23 @@ int Rig::FindJoint(const char* jointName) { for (unsigned int i = 0; i < mNumJoints; i++) { - if (strstr(mSkeleton.joint_names()[i], jointName)) + if (strcmp(mSkeleton.joint_names()[i], jointName) == 0) return i; } return -1; } + +void Rig::FindJointChain(const char* jointNames[], size_t numNames, int jointChain[]) +{ + int found = 0; + for (int i = 0; i < mSkeleton.num_joints() && found < numNames; ++i) + { + const char* joint_name = mSkeleton.joint_names()[i]; + if (strcmp(joint_name, jointNames[found]) == 0) + { + jointChain[found] = i; + ++found; + i = 0; + } + } +} \ No newline at end of file diff --git a/Middleware_3/Animation/Rig.h b/Middleware_3/Animation/Rig.h index 1a95f341c4..f326d84939 100644 --- a/Middleware_3/Animation/Rig.h +++ b/Middleware_3/Animation/Rig.h @@ -139,6 +139,9 @@ class Rig // Finds the index of the joint with name jointName, if it cannot find it returns -1 int FindJoint(const char* jointName); + // Finds the indexes of joint chain with names joinNames + void FindJointChain(const char* jointNames[], size_t numNames, int jointChain[]); + private: // Load a runtime skeleton from a skeleton.ozz file bool LoadSkeleton(const char* fileName);