rename ResourceInitializer to ResourceUploader

refresh2
cosmonaut 2024-02-23 14:32:56 -08:00
parent 795331c133
commit cd235b9172
19 changed files with 118 additions and 121 deletions

View File

@ -83,8 +83,8 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo()); sampler = new Sampler(GraphicsDevice, new SamplerCreateInfo());
// Upload GPU resources and dispatch compute work // Upload GPU resources and dispatch compute work
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -96,8 +96,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();

View File

@ -61,9 +61,9 @@ namespace MoonWorks.Test
TextureUsageFlags.DepthStencilTarget TextureUsageFlags.DepthStencilTarget
); );
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionColorVertex(new Vector3(-0.5f, 0.5f, 0), Color.Yellow), new PositionColorVertex(new Vector3(-0.5f, 0.5f, 0), Color.Yellow),
new PositionColorVertex(new Vector3(0.5f, 0.5f, 0), Color.Yellow), new PositionColorVertex(new Vector3(0.5f, 0.5f, 0), Color.Yellow),
@ -76,8 +76,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) { } protected override void Update(System.TimeSpan delta) { }

View File

@ -47,9 +47,9 @@ namespace MoonWorks.Test
textures = new Texture[textureNames.Length]; textures = new Texture[textureNames.Length];
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -59,7 +59,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -70,11 +70,11 @@ namespace MoonWorks.Test
for (int i = 0; i < textureNames.Length; i += 1) for (int i = 0; i < textureNames.Length; i += 1)
{ {
Logger.LogInfo(textureNames[i]); Logger.LogInfo(textureNames[i]);
textures[i] = resourceInitializer.CreateTextureFromDDS(TestUtils.GetTexturePath(textureNames[i] + ".dds")); textures[i] = resourceUploader.CreateTextureFromDDS(TestUtils.GetTexturePath(textureNames[i] + ".dds"));
} }
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)

View File

@ -72,9 +72,9 @@ namespace MoonWorks.Test
// Upload GPU resources and dispatch compute work // Upload GPU resources and dispatch compute work
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -86,8 +86,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer();
GradientTextureComputeUniforms gradientUniforms = new GradientTextureComputeUniforms( GradientTextureComputeUniforms gradientUniforms = new GradientTextureComputeUniforms(

View File

@ -35,9 +35,9 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1f, 0f, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1f, 0f, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3( 0f, 0f, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3( 0f, 0f, 0), new Vector2(1, 0)),
@ -57,7 +57,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -65,12 +65,12 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
originalTexture = resourceInitializer.CreateTexture2D( originalTexture = resourceUploader.CreateTexture2D(
TestUtils.GetTexturePath("ravioli.png") TestUtils.GetTexturePath("ravioli.png")
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
// Load the texture bytes so we can compare them. // Load the texture bytes so we can compare them.
var pixels = ImageUtils.GetPixelDataFromFile( var pixels = ImageUtils.GetPixelDataFromFile(

View File

@ -55,7 +55,7 @@ namespace MoonWorks.Test
// Upload cubemap layers one at a time to minimize transfer size // Upload cubemap layers one at a time to minimize transfer size
unsafe void LoadCubemap(string[] imagePaths) unsafe void LoadCubemap(string[] imagePaths)
{ {
var cubemapUploader = new ResourceInitializer(GraphicsDevice); var cubemapUploader = new ResourceUploader(GraphicsDevice);
for (uint i = 0; i < imagePaths.Length; i++) for (uint i = 0; i < imagePaths.Length; i++)
{ {
@ -304,15 +304,15 @@ namespace MoonWorks.Test
new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)), new PositionTextureVertex(new Vector3(-1, 1, 0), new Vector2(0, 1)),
]); ]);
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
cubeVertexBuffer = resourceInitializer.CreateBuffer(cubeVertexData, BufferUsageFlags.Vertex); cubeVertexBuffer = resourceUploader.CreateBuffer(cubeVertexData, BufferUsageFlags.Vertex);
skyboxVertexBuffer = resourceInitializer.CreateBuffer(skyboxVertexData, BufferUsageFlags.Vertex); skyboxVertexBuffer = resourceUploader.CreateBuffer(skyboxVertexData, BufferUsageFlags.Vertex);
indexBuffer = resourceInitializer.CreateBuffer(indexData, BufferUsageFlags.Index); indexBuffer = resourceUploader.CreateBuffer(indexData, BufferUsageFlags.Index);
blitVertexBuffer = resourceInitializer.CreateBuffer(blitVertexData, BufferUsageFlags.Vertex); blitVertexBuffer = resourceUploader.CreateBuffer(blitVertexData, BufferUsageFlags.Vertex);
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
LoadCubemap(new string[] LoadCubemap(new string[]
{ {

View File

@ -52,9 +52,9 @@ namespace MoonWorks.Test
CCW_CullBackPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); CCW_CullBackPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create and populate the vertex buffers // Create and populate the vertex buffers
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
cwVertexBuffer = resourceInitializer.CreateBuffer( cwVertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue), new PositionColorVertex(new Vector3(0, -1, 0), Color.Blue),
new PositionColorVertex(new Vector3(1, 1, 0), Color.Green), new PositionColorVertex(new Vector3(1, 1, 0), Color.Green),
@ -63,7 +63,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
ccwVertexBuffer = resourceInitializer.CreateBuffer( ccwVertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red), new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
new PositionColorVertex(new Vector3(1, 1, 0), Color.Green), new PositionColorVertex(new Vector3(1, 1, 0), Color.Green),
@ -72,8 +72,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)

View File

@ -105,9 +105,9 @@ namespace MoonWorks.Test
rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create the buffers // Create the buffers
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
quadVertexBuffer = resourceInitializer.CreateBuffer( quadVertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -117,7 +117,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
quadIndexBuffer = resourceInitializer.CreateBuffer<ushort>( quadIndexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -158,7 +158,7 @@ namespace MoonWorks.Test
new PositionColorVertex(new Vector3(1, 1, -1), new Color(0f, 0.5f, 0f)) new PositionColorVertex(new Vector3(1, 1, -1), new Color(0f, 0.5f, 0f))
]); ]);
cubeVertexBuffer1 = resourceInitializer.CreateBuffer( cubeVertexBuffer1 = resourceUploader.CreateBuffer(
cubeVertexData, cubeVertexData,
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
@ -169,12 +169,12 @@ namespace MoonWorks.Test
cubeVertexData[i].Position.Z += 3; cubeVertexData[i].Position.Z += 3;
} }
cubeVertexBuffer2 = resourceInitializer.CreateBuffer( cubeVertexBuffer2 = resourceUploader.CreateBuffer(
cubeVertexData, cubeVertexData,
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
cubeIndexBuffer = resourceInitializer.CreateBuffer<uint>( cubeIndexBuffer = resourceUploader.CreateBuffer<uint>(
[ [
0, 1, 2, 0, 2, 3, 0, 1, 2, 0, 2, 3,
6, 5, 4, 7, 6, 4, 6, 5, 4, 7, 6, 4,
@ -186,8 +186,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)

View File

@ -26,9 +26,9 @@ namespace MoonWorks.Test
graphicsPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); graphicsPipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create and populate the vertex buffer // Create and populate the vertex buffer
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionColorVertex(new Vector3(-0.5f, -1, 0), Color.Blue), new PositionColorVertex(new Vector3(-0.5f, -1, 0), Color.Blue),
new PositionColorVertex(new Vector3(-1f, 1, 0), Color.Green), new PositionColorVertex(new Vector3(-1f, 1, 0), Color.Green),
@ -41,7 +41,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
drawBuffer = resourceInitializer.CreateBuffer( drawBuffer = resourceUploader.CreateBuffer(
[ [
new IndirectDrawCommand(3, 1, 3, 0), new IndirectDrawCommand(3, 1, 3, 0),
new IndirectDrawCommand(3, 1, 0, 0), new IndirectDrawCommand(3, 1, 0, 0),
@ -49,8 +49,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Indirect BufferUsageFlags.Indirect
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) { } protected override void Update(System.TimeSpan delta) { }

View File

@ -29,12 +29,12 @@ namespace MoonWorks.Test
int vertexSize = Marshal.SizeOf<PositionVertex>(); int vertexSize = Marshal.SizeOf<PositionVertex>();
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
var vertexBuffer = resourceInitializer.CreateBuffer(vertices, BufferUsageFlags.Vertex); var vertexBuffer = resourceUploader.CreateBuffer(vertices, BufferUsageFlags.Vertex);
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
var transferBuffer = new TransferBuffer(GraphicsDevice, vertexBuffer.Size); var transferBuffer = new TransferBuffer(GraphicsDevice, vertexBuffer.Size);

View File

@ -31,9 +31,9 @@ namespace MoonWorks.Test
pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo); pipeline = new GraphicsPipeline(GraphicsDevice, pipelineCreateInfo);
// Create and populate the vertex and index buffers // Create and populate the vertex and index buffers
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red), new PositionColorVertex(new Vector3(-1, 1, 0), Color.Red),
new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime), new PositionColorVertex(new Vector3(1, 1, 0), Color.Lime),
@ -50,7 +50,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
3, 4, 5, 3, 4, 5,
@ -58,8 +58,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)

View File

@ -67,9 +67,9 @@ namespace MoonWorks.Test
rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); rtSampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the vertex and index buffers // Create and populate the vertex and index buffers
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
quadVertexBuffer = resourceInitializer.CreateBuffer( quadVertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -79,7 +79,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
quadIndexBuffer = resourceInitializer.CreateBuffer<ushort>( quadIndexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3 0, 2, 3
@ -87,8 +87,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)

View File

@ -12,8 +12,8 @@ namespace MoonWorks.Test
private GraphicsPipeline cubemapPipeline; private GraphicsPipeline cubemapPipeline;
private Texture[] renderTargets = new Texture[4]; private Texture[] renderTargets = new Texture[4];
private Buffer vertexBuffer; private GpuBuffer vertexBuffer;
private Buffer indexBuffer; private GpuBuffer indexBuffer;
private Sampler sampler; private Sampler sampler;
private Vector3 camPos = new Vector3(0, 0, 4f); private Vector3 camPos = new Vector3(0, 0, 4f);
@ -76,14 +76,10 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the GPU resources // Create and populate the GPU resources
vertexBuffer = Buffer.Create<PositionVertex>(GraphicsDevice, BufferUsageFlags.Vertex, 24); var resourceUploader = new ResourceUploader(GraphicsDevice);
indexBuffer = Buffer.Create<ushort>(GraphicsDevice, BufferUsageFlags.Index, 36);
CommandBuffer cmdbuf = GraphicsDevice.AcquireCommandBuffer(); vertexBuffer = resourceUploader.CreateBuffer(
cmdbuf.SetBufferData( [
vertexBuffer,
new PositionVertex[]
{
new PositionVertex(new Vector3(-10, -10, -10)), new PositionVertex(new Vector3(-10, -10, -10)),
new PositionVertex(new Vector3(10, -10, -10)), new PositionVertex(new Vector3(10, -10, -10)),
new PositionVertex(new Vector3(10, 10, -10)), new PositionVertex(new Vector3(10, 10, -10)),
@ -113,23 +109,24 @@ namespace MoonWorks.Test
new PositionVertex(new Vector3(-10, 10, 10)), new PositionVertex(new Vector3(-10, 10, 10)),
new PositionVertex(new Vector3(10, 10, 10)), new PositionVertex(new Vector3(10, 10, 10)),
new PositionVertex(new Vector3(10, 10, -10)) new PositionVertex(new Vector3(10, 10, -10))
} ],
BufferUsageFlags.Vertex
); );
cmdbuf.SetBufferData( indexBuffer = resourceUploader.CreateBuffer<ushort>(
indexBuffer, [
new ushort[] 0, 1, 2, 0, 2, 3,
{ 6, 5, 4, 7, 6, 4,
0, 1, 2, 0, 2, 3, 8, 9, 10, 8, 10, 11,
6, 5, 4, 7, 6, 4,
8, 9, 10, 8, 10, 11,
14, 13, 12, 15, 14, 12, 14, 13, 12, 15, 14, 12,
16, 17, 18, 16, 18, 19, 16, 17, 18, 16, 18, 19,
22, 21, 20, 23, 22, 20 22, 21, 20, 23, 22, 20
} ],
BufferUsageFlags.Index
); );
GraphicsDevice.Submit(cmdbuf); resourceUploader.Upload();
resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)
@ -198,7 +195,7 @@ namespace MoonWorks.Test
cmdbuf.BeginRenderPass(rtAttachmentInfo); cmdbuf.BeginRenderPass(rtAttachmentInfo);
cmdbuf.BindGraphicsPipeline(msaaPipelines[rtIndex]); cmdbuf.BindGraphicsPipeline(msaaPipelines[rtIndex]);
cmdbuf.DrawPrimitives(0, 1, 0, 0); cmdbuf.DrawPrimitives(0, 1);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
@ -207,8 +204,8 @@ namespace MoonWorks.Test
cmdbuf.BindVertexBuffers(vertexBuffer); cmdbuf.BindVertexBuffers(vertexBuffer);
cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen); cmdbuf.BindIndexBuffer(indexBuffer, IndexElementSize.Sixteen);
cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, sampler)); cmdbuf.BindFragmentSamplers(new TextureSamplerBinding(rt, sampler));
uint vertexUniformOffset = cmdbuf.PushVertexShaderUniforms(vertUniforms); cmdbuf.PushVertexShaderUniforms(vertUniforms);
cmdbuf.DrawIndexedPrimitives(0, 0, 12, vertexUniformOffset, 0); cmdbuf.DrawIndexedPrimitives(0, 0, 12);
cmdbuf.EndRenderPass(); cmdbuf.EndRenderPass();
} }
GraphicsDevice.Submit(cmdbuf); GraphicsDevice.Submit(cmdbuf);

View File

@ -34,9 +34,9 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, samplerCreateInfo); sampler = new Sampler(GraphicsDevice, samplerCreateInfo);
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(0, -1, 0), new Vector2(1, 0)),
@ -61,7 +61,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -69,8 +69,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
for (int i = 0; i < textures.Length; i += 1) for (int i = 0; i < textures.Length; i += 1)
{ {

View File

@ -49,9 +49,9 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.LinearWrap);
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -61,7 +61,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -69,8 +69,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
rt = Texture.CreateTexture3D( rt = Texture.CreateTexture3D(
GraphicsDevice, GraphicsDevice,

View File

@ -48,9 +48,9 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionVertex(new Vector3(-10, -10, -10)), new PositionVertex(new Vector3(-10, -10, -10)),
new PositionVertex(new Vector3(10, -10, -10)), new PositionVertex(new Vector3(10, -10, -10)),
@ -85,7 +85,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 2, 3, 0, 1, 2, 0, 2, 3,
6, 5, 4, 7, 6, 4, 6, 5, 4, 7, 6, 4,
@ -97,8 +97,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
cubemap = Texture.CreateTextureCube( cubemap = Texture.CreateTextureCube(
GraphicsDevice, GraphicsDevice,

View File

@ -82,9 +82,9 @@ namespace MoonWorks.Test
samplers[4] = new Sampler(GraphicsDevice, samplerCreateInfo); samplers[4] = new Sampler(GraphicsDevice, samplerCreateInfo);
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -94,7 +94,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -102,8 +102,8 @@ namespace MoonWorks.Test
BufferUsageFlags.Index BufferUsageFlags.Index
); );
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
texture = Texture.CreateTexture2D( texture = Texture.CreateTexture2D(
GraphicsDevice, GraphicsDevice,

View File

@ -45,9 +45,9 @@ namespace MoonWorks.Test
sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp); sampler = new Sampler(GraphicsDevice, SamplerCreateInfo.PointClamp);
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer( vertexBuffer = resourceUploader.CreateBuffer(
[ [
new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)), new PositionTextureVertex(new Vector3(-1, -1, 0), new Vector2(0, 0)),
new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)), new PositionTextureVertex(new Vector3(1, -1, 0), new Vector2(1, 0)),
@ -57,7 +57,7 @@ namespace MoonWorks.Test
BufferUsageFlags.Vertex BufferUsageFlags.Vertex
); );
indexBuffer = resourceInitializer.CreateBuffer<ushort>( indexBuffer = resourceUploader.CreateBuffer<ushort>(
[ [
0, 1, 2, 0, 1, 2,
0, 2, 3, 0, 2, 3,
@ -84,14 +84,14 @@ namespace MoonWorks.Test
Depth = 1 Depth = 1
}; };
resourceInitializer.SetTextureDataFromCompressed( resourceUploader.SetTextureDataFromCompressed(
slice, slice,
TestUtils.GetTexturePath($"tex3d_{i}.png") TestUtils.GetTexturePath($"tex3d_{i}.png")
); );
} }
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)

View File

@ -85,18 +85,18 @@ namespace MoonWorks.Test
// Create and populate the GPU resources // Create and populate the GPU resources
var resourceInitializer = new ResourceInitializer(GraphicsDevice); var resourceUploader = new ResourceUploader(GraphicsDevice);
vertexBuffer = resourceInitializer.CreateBuffer(vertexData, BufferUsageFlags.Vertex); vertexBuffer = resourceUploader.CreateBuffer(vertexData, BufferUsageFlags.Vertex);
indexBuffer = resourceInitializer.CreateBuffer(indexData, BufferUsageFlags.Index); indexBuffer = resourceUploader.CreateBuffer(indexData, BufferUsageFlags.Index);
textures[0] = resourceInitializer.CreateTexture2D(TestUtils.GetTexturePath("ravioli.png")); textures[0] = resourceUploader.CreateTexture2D(TestUtils.GetTexturePath("ravioli.png"));
textures[1] = resourceInitializer.CreateTexture2D(pngBytes); textures[1] = resourceUploader.CreateTexture2D(pngBytes);
textures[2] = resourceInitializer.CreateTexture2D(TestUtils.GetTexturePath("ravioli.qoi")); textures[2] = resourceUploader.CreateTexture2D(TestUtils.GetTexturePath("ravioli.qoi"));
textures[3] = resourceInitializer.CreateTexture2D(qoiBytes); textures[3] = resourceUploader.CreateTexture2D(qoiBytes);
resourceInitializer.Upload(); resourceUploader.Upload();
resourceInitializer.Dispose(); resourceUploader.Dispose();
} }
protected override void Update(System.TimeSpan delta) protected override void Update(System.TimeSpan delta)