| 127 | } |
| 128 | |
| 129 | void SpriteRenderer::Begin(ID3D12GraphicsCommandList* cmdList, Float2 viewportSize, SpriteFilterMode filterMode, SpriteBlendMode blendMode) |
| 130 | { |
| 131 | cmdList->SetPipelineState(pipelineStates[uint64(blendMode)]); |
| 132 | cmdList->SetGraphicsRootSignature(rootSignature); |
| 133 | |
| 134 | perBatchCB.Data.LinearSampling = filterMode == SpriteFilterMode::Linear ? 1 : 0; |
| 135 | perBatchCB.Data.ViewportSize = viewportSize; |
| 136 | |
| 137 | cmdList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); |
| 138 | |
| 139 | D3D12_INDEX_BUFFER_VIEW ibView = { }; |
| 140 | ibView.BufferLocation = indexBuffer.GPUAddress; |
| 141 | ibView.SizeInBytes = uint32(indexBuffer.Size); |
| 142 | ibView.Format = DXGI_FORMAT_R16_UINT; |
| 143 | cmdList->IASetIndexBuffer(&ibView); |
| 144 | } |
| 145 | |
| 146 | void SpriteRenderer::Render(ID3D12GraphicsCommandList* cmdList, const Texture* texture, const SpriteTransform& transform, |
| 147 | const Float4& color, const Float4* drawRect) |