Refactor shader pipeline and improve modularity
- Added `generatedCodePath` to `FullPassDescriptor` for better shader code organization. - Removed redundant `IID_PPV_ARGS` method and unused `Misaki.HighPerformance.Unsafe` reference. - Refactored `Material` and `MaterialAccessor` to use `CBuffer` and updated buffer size handling. - Renamed command buffer variables in `RenderingContext` for consistency. - Updated `D3D12PipelineLibrary` to cache compiled shader results and added `ShaderPassKey`. - Refactored `D3D12GraphicsEngine` to integrate `_copyCommandBuffer` lifecycle. - Enhanced `D3D12ResourceAllocator` with shader pass creation using constant buffer info. - Simplified `D3D12ShaderCompiler` with `GENERATED_CODE_PATH` support and improved reflection handling. - Introduced `CBufferPropertyInfo` and `CBufferInfo` structs for better encapsulation. - Updated HLSL shaders to use `g_PerMaterialData` and dynamic includes. - Improved error handling in `SDLCompiler` with try-catch blocks and better messages. - Refactored `test.gshader` to use dynamically generated includes. - Fixed typos, improved code readability, and removed unused code.
This commit is contained in:
@@ -63,17 +63,17 @@ public struct Material : IResourceReleasable, IHandleType
|
||||
for (var i = 0; i < shader.PassCount; i++)
|
||||
{
|
||||
var pass = database.GetShaderPass(shader.GetPassKey(i));
|
||||
var cbufferInfo = pass.PassPropertyInfo;
|
||||
var cbufferInfo = pass.CBuffer;
|
||||
|
||||
var desc = new BufferDesc
|
||||
{
|
||||
Size = cbufferInfo.Size,
|
||||
Size = cbufferInfo.SizeInBytes,
|
||||
Usage = BufferUsage.Constant,
|
||||
MemoryType = ResourceMemoryType.Default,
|
||||
};
|
||||
|
||||
var buffer = allocator.CreateBuffer(ref desc);
|
||||
_materialPropertiesCache[i] = new CBufferCache(buffer, cbufferInfo.Size);
|
||||
_materialPropertiesCache[i] = new CBufferCache(buffer, cbufferInfo.SizeInBytes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public ref struct MaterialAccessor
|
||||
}
|
||||
|
||||
ref var cache = ref _materialData.GetPassCache(index);
|
||||
Unsafe.WriteUnaligned(ref cache.CpuData[propertyInfo.ByteOffset], value);
|
||||
Unsafe.WriteUnaligned(ref cache.CpuData[propertyInfo.StartOffset], value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user