123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- #include "DX12Shader.h"
- #include "d3dx12.h"
- #include "DX12CommandQueue.h"
- using namespace Framework;
- DX12Shader::DX12Shader(ID3D12Device* device,
- DX12CopyCommandQueue* copy,
- DX12DirectCommandQueue* direct)
- : Shader()
- {
- shaderByteBuffer = 0;
- byteBufferSize = 0;
- this->device = device;
- this->copy = copy;
- this->direct = direct;
- }
- DX12Shader::~DX12Shader()
- {
- delete[] shaderByteBuffer;
- }
- bool DX12Shader::erstelleConstBuffer(int size, int index)
- {
- if (index < 0 || index >= 14) return 0;
- while ((size / 256) * 256 != size)
- size++;
- while (!constBuffers->hat(index))
- constBuffers->add(0);
- constBuffers->set(new DX12VertexBuffer(1, device, copy, direct), index);
- constBuffers->z(index)->setLength(size);
- constBuffers->z(index)->copieren();
- return 1;
- }
- bool DX12Shader::setCompiledByteArray(unsigned char* bytes, int length)
- {
- delete[] shaderByteBuffer;
- shaderByteBuffer = new unsigned char[length];
- memcpy(shaderByteBuffer, bytes, length);
- byteBufferSize = length;
- return 1;
- }
- void DX12Shader::benutzeShader()
- {
-
- }
- unsigned char* DX12Shader::getCompiledShader() const
- {
- return shaderByteBuffer;
- }
- int DX12Shader::getCompiledLength() const
- {
- return byteBufferSize;
- }
- void DX12Shader::getViewDesc(int index, D3D12_CONSTANT_BUFFER_VIEW_DESC& view)
- {
- DX12Buffer* zB = (DX12Buffer*)constBuffers->z(index);
- if (!zB) return;
- view.SizeInBytes = zB->getElementAnzahl() * zB->getElementLength();
- view.BufferLocation = zB->zBuffer()->GetGPUVirtualAddress();
- }
- DX12PixelShader::DX12PixelShader(ID3D12Device* device,
- DX12CopyCommandQueue* copy,
- DX12DirectCommandQueue* direct)
- : DX12Shader(device, copy, direct)
- {}
- DX12VertexShader::DX12VertexShader(ID3D12Device* device,
- DX12CopyCommandQueue* copy,
- DX12DirectCommandQueue* direct)
- : DX12Shader(device, copy, direct)
- {
- inputLayout = 0;
- inputLayoutSize = 0;
- }
- DX12VertexShader::~DX12VertexShader()
- {
- delete[] inputLayout;
- }
- bool DX12VertexShader::erstelleInputLayout(
- D3D12_INPUT_ELEMENT_DESC* descArray, int anz)
- {
- delete[] inputLayout;
- inputLayout = new D3D12_INPUT_ELEMENT_DESC[anz];
- memcpy(inputLayout, descArray, anz * sizeof(D3D12_INPUT_ELEMENT_DESC));
- inputLayoutSize = anz;
- return 1;
- }
- int DX12VertexShader::getInputLayoutSize() const
- {
- return inputLayoutSize;
- }
- D3D12_INPUT_ELEMENT_DESC* DX12VertexShader::zInputLayout() const
- {
- return inputLayout;
- }
|