public MainPage() { this.InitializeComponent(); m_ctx = new ResourceCreateContext(); m_swapChain = new CompositionSwapChainResources(m_ctx, m_swapChainPanel); var display = DisplayInformation.GetForCurrentView(); display.DpiChanged += new TypedEventHandler <DisplayInformation, object>(OnDpiChanged); m_triangle = makeTriangle(m_ctx); m_compute = makeCompute(m_ctx); m_buffer = m_ctx.CreateByteAddressBuffer(4096, ResourceState.CopyDestination); m_texture = m_ctx.CreateTexture2D(256, 256, 1, GraphicsFormat.R8_UNORM, ResourceState.CopyDestination); var ctx = m_swapChain.CreateGraphicsComputeCommandContext(); { float[] positions = { 0.0f, 0.5f, 0.5f, 1.0f, -0.5f, 0.0f, 0.5f, 1.0f, 0.5f, 0.0f, 0.5f, 1.0f }; byte[] b0 = new byte[positions.Length * 4]; Buffer.BlockCopy(positions, 0, b0, 0, b0.Length); float[] colors = { 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; byte[] b1 = new byte[colors.Length * 4]; Buffer.BlockCopy(colors, 0, b1, 0, b1.Length); ctx.UpdateBuffer(m_buffer, 0, b0); ctx.UpdateBuffer(m_buffer, (uint)b0.Length, b1); } { var subResourceData = new SubresourceData(); subResourceData.Data = GenerateTextureData(); subResourceData.RowPitch = 256; subResourceData.SlicePitch = 256 * 256; SubresourceData[] datas = { subResourceData }; ctx.UploadResource(m_texture, 0, 1, datas); } ctx.TransitionResource(m_texture, ResourceState.CopyDestination, ResourceState.PixelShaderResource | ResourceState.NonPixelShaderResource); ctx.TransitionResource(m_buffer, ResourceState.CopyDestination, ResourceState.NonPixelShaderResource); ctx.SubmitAndWaitToExecute(); }
public MainPage() { this.InitializeComponent(); m_ctx = new ResourceCreateContext(); m_swapChain = new CompositionSwapChainResources(m_ctx, m_swapChainPanel); var display = DisplayInformation.GetForCurrentView(); display.DpiChanged += new TypedEventHandler <DisplayInformation, object>(OnDpiChanged); var ctx = m_swapChain.CreateGraphicsComputeCommandContext(); m_mechanicMaterial = new DerivativesSkinnedMaterial(m_ctx, ctx, ""); m_mechanicModel = new DerivativesSkinnedModel(m_mechanicMaterial, m_ctx, ctx, @"Assets\\models\\military_mechanic.derivatives_skinned_model.model"); m_mechanicInstance = new DerivativesSkinnedModelInstance(m_mechanicModel, identity()); ctx.SubmitAndWaitToExecute(); m_lighting = makeLighting(m_ctx); }