diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 73479dcd2b..7ad10d0235 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#ifdef DX12_SUPPORT #include "BufferUtils.h" @@ -13,20 +12,22 @@ bool overlaps(const std::pair &range1, const std::pair FormatVertexData(const RSXVertexData *m_vertex_data, size_t *vertex_data_size, size_t base_offset) +std::vector FormatVertexData(const rsx::data_array_format_info *vertex_array_desc, const std::vector *vertex_data, size_t *vertex_data_size, size_t base_offset) { std::vector Result; - for (size_t i = 0; i < 32; ++i) + for (size_t i = 0; i < rsx::limits::vertex_count; ++i) { - const RSXVertexData &vertexData = m_vertex_data[i]; - if (!vertexData.IsEnabled()) continue; + const rsx::data_array_format_info &vertexData = vertex_array_desc[i]; + if (!vertexData.size) continue; - size_t elementCount = ((vertexData.addr) ? vertex_data_size[i] : m_vertex_data[i].data.size()) / (vertexData.size * vertexData.GetTypeSize()); + u32 addrRegVal = rsx::method_registers[NV4097_SET_VERTEX_DATA_ARRAY_OFFSET + i]; + u32 addr = rsx::get_address(addrRegVal & 0x7fffffff, addrRegVal >> 31); + size_t elementCount = ((vertexData.array) ? vertex_data_size[i] : vertex_data[i].size()) / (vertexData.size * rsx::get_vertex_type_size(vertexData.type)); // If there is a single element, stride is 0, use the size of element instead size_t stride = vertexData.stride; - size_t elementSize = vertexData.GetTypeSize(); - size_t start = vertexData.addr + base_offset; + size_t elementSize = rsx::get_vertex_type_size(vertexData.type); + size_t start = addr + base_offset; size_t end = start + elementSize * vertexData.size + (elementCount - 1) * stride - 1; std::pair range = std::make_pair(start, end); assert(start < end); @@ -54,21 +55,24 @@ std::vector FormatVertexData(const RSXVertexData *m_vertex_d return Result; } -void uploadVertexData(const VertexBufferFormat &vbf, const RSXVertexData *vertexData, size_t baseOffset, void* bufferMap) +void uploadVertexData(const VertexBufferFormat &vbf, const rsx::data_array_format_info *vertex_array_desc, const std::vector *vertex_data, size_t baseOffset, void* bufferMap) { for (int vertex = 0; vertex < vbf.elementCount; vertex++) { for (size_t attributeId : vbf.attributeId) { - if (!vertexData[attributeId].addr) + u32 addrRegVal = rsx::method_registers[NV4097_SET_VERTEX_DATA_ARRAY_OFFSET + attributeId]; + u32 addr = rsx::get_address(addrRegVal & 0x7fffffff, addrRegVal >> 31); + + if (!vertex_array_desc[attributeId].array) { - memcpy(bufferMap, vertexData[attributeId].data.data(), vertexData[attributeId].data.size()); + memcpy(bufferMap, vertex_data[attributeId].data(), vertex_data[attributeId].size()); continue; } - size_t offset = (size_t)vertexData[attributeId].addr + baseOffset - vbf.range.first; - size_t tsize = vertexData[attributeId].GetTypeSize(); - size_t size = vertexData[attributeId].size; - auto src = vm::get_ptr(vertexData[attributeId].addr + (u32)baseOffset + (u32)vbf.stride * vertex); + size_t offset = (size_t)addr + baseOffset - vbf.range.first; + size_t tsize = rsx::get_vertex_type_size(vertex_array_desc[attributeId].type); + size_t size = vertex_array_desc[attributeId].size; + auto src = vm::get_ptr(addr + (u32)baseOffset + (u32)vbf.stride * vertex); char* dst = (char*)bufferMap + offset + vbf.stride * vertex; switch (tsize) @@ -244,5 +248,4 @@ void uploadIndexData(unsigned m_draw_mode, unsigned index_type, void* indexBuffe return; } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index 5da0935a27..874d673241 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -1,4 +1,3 @@ -#ifdef DX12_SUPPORT #pragma once #include #include "Emu/Memory/vm.h" @@ -18,12 +17,12 @@ struct VertexBufferFormat * Detect buffer containing interleaved vertex attribute. * This minimizes memory upload size. */ -std::vector FormatVertexData(const RSXVertexData *m_vertex_data, size_t *vertex_data_size, size_t base_offset); +std::vector FormatVertexData(const rsx::data_array_format_info *vertex_array_desc, const std::vector *vertex_data, size_t *vertex_data_size, size_t base_offset); /* * Write vertex attributes to bufferMap, swapping data as required. */ -void uploadVertexData(const VertexBufferFormat &vbf, const RSXVertexData *vertexData, size_t baseOffset, void* bufferMap); +void uploadVertexData(const VertexBufferFormat &vbf, const rsx::data_array_format_info *vertex_array_desc, const std::vector *vertex_data, size_t baseOffset, void* bufferMap); /* * If primitive mode is not supported and need to be emulated (using an index buffer) returns false. @@ -38,5 +37,4 @@ size_t getIndexCount(unsigned m_draw_mode, unsigned initial_index_count); /* * Write index information to bufferMap */ -void uploadIndexData(unsigned m_draw_mode, unsigned index_type, void* indexBuffer, void* bufferMap, unsigned element_count); -#endif \ No newline at end of file +void uploadIndexData(unsigned m_draw_mode, unsigned index_type, void* indexBuffer, void* bufferMap, unsigned element_count); \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 71e5b61a1e..ac8c5da9df 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -1,5 +1,4 @@ #include "stdafx.h" -#ifdef DX12_SUPPORT #include "Emu/Memory/vm.h" #include "TextureUtils.h" #include "../RSXThread.h" @@ -8,37 +7,6 @@ #define MAX2(a, b) ((a) > (b)) ? (a) : (b) -unsigned LinearToSwizzleAddress(unsigned x, unsigned y, unsigned z, unsigned log2_width, unsigned log2_height, unsigned log2_depth) -{ - unsigned offset = 0; - unsigned shift_count = 0; - while (log2_width | log2_height | log2_depth) { - if (log2_width) - { - offset |= (x & 0x01) << shift_count; - x >>= 1; - ++shift_count; - --log2_width; - } - if (log2_height) - { - offset |= (y & 0x01) << shift_count; - y >>= 1; - ++shift_count; - --log2_height; - } - if (log2_depth) - { - offset |= (z & 0x01) << shift_count; - z >>= 1; - ++shift_count; - --log2_depth; - } - } - return offset; -} - - /** * Write data, assume src pixels are packed but not mipmaplevel */ @@ -102,7 +70,7 @@ writeTexelsSwizzled(const char *src, char *dst, size_t widthInBlock, size_t heig for (int row = 0; row < currentHeight; row++) for (int j = 0; j < currentWidth; j++) - castedDst[(row * rowPitch / 4) + j] = castedSrc[LinearToSwizzleAddress(j, row, 0, log2width, log2height, 0)]; + castedDst[(row * rowPitch / 4) + j] = castedSrc[rsx::linear_to_swizzle(j, row, 0, log2width, log2height, 0)]; offsetInDst += currentHeight * rowPitch; offsetInSrc += currentHeight * widthInBlock * blockSize; @@ -177,7 +145,7 @@ write16bTexelsSwizzled(const char *src, char *dst, size_t widthInBlock, size_t h for (int row = 0; row < currentHeight; row++) for (int j = 0; j < currentWidth; j++) - castedDst[(row * rowPitch / 2) + j] = castedSrc[LinearToSwizzleAddress(j, row, 0, log2width, log2height, 0)]; + castedDst[(row * rowPitch / 2) + j] = castedSrc[rsx::linear_to_swizzle(j, row, 0, log2width, log2height, 0)]; offsetInDst += currentHeight * rowPitch; offsetInSrc += currentHeight * widthInBlock * blockSize; @@ -264,12 +232,12 @@ write16bX4TexelsGeneric(const char *src, char *dst, size_t widthInBlock, size_t } -size_t getPlacedTextureStorageSpace(const RSXTexture &texture, size_t rowPitchAlignement) +size_t getPlacedTextureStorageSpace(const rsx::texture &texture, size_t rowPitchAlignement) { - size_t w = texture.GetWidth(), h = texture.GetHeight(); + size_t w = texture.width(), h = texture.height(); size_t blockSizeInByte, blockWidthInPixel, blockHeightInPixel; - int format = texture.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); switch (format) { @@ -391,11 +359,11 @@ size_t getPlacedTextureStorageSpace(const RSXTexture &texture, size_t rowPitchAl return rowPitch * heightInBlocks * 2; // * 2 for mipmap levels } -std::vector uploadPlacedTexture(const RSXTexture &texture, size_t rowPitchAlignement, void* textureData) +std::vector uploadPlacedTexture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData) { - size_t w = texture.GetWidth(), h = texture.GetHeight(); + size_t w = texture.width(), h = texture.height(); - int format = texture.GetFormat() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); size_t blockSizeInByte, blockWidthInPixel, blockHeightInPixel; switch (format) @@ -515,32 +483,31 @@ std::vector uploadPlacedTexture(const RSXTexture &texture, size std::vector mipInfos; - const u32 texaddr = GetAddress(texture.GetOffset(), texture.GetLocation()); + const u32 texaddr = rsx::get_address(texture.offset(), texture.location()); auto pixels = vm::get_ptr(texaddr); - bool is_swizzled = !(texture.GetFormat() & CELL_GCM_TEXTURE_LN); + bool is_swizzled = !(texture.format() & CELL_GCM_TEXTURE_LN); switch (format) { case CELL_GCM_TEXTURE_A8R8G8B8: if (is_swizzled) - return writeTexelsSwizzled((char*)pixels, (char*)textureData, w, h, 4, texture.GetMipmap()); + return writeTexelsSwizzled((char*)pixels, (char*)textureData, w, h, 4, texture.mipmap()); else - return writeTexelsGeneric((char*)pixels, (char*)textureData, w, h, 4, texture.GetMipmap()); + return writeTexelsGeneric((char*)pixels, (char*)textureData, w, h, 4, texture.mipmap()); case CELL_GCM_TEXTURE_A1R5G5B5: case CELL_GCM_TEXTURE_A4R4G4B4: case CELL_GCM_TEXTURE_R5G6B5: if (is_swizzled) - return write16bTexelsSwizzled((char*)pixels, (char*)textureData, w, h, 2, texture.GetMipmap()); + return write16bTexelsSwizzled((char*)pixels, (char*)textureData, w, h, 2, texture.mipmap()); else - return write16bTexelsGeneric((char*)pixels, (char*)textureData, w, h, 2, texture.GetMipmap()); + return write16bTexelsGeneric((char*)pixels, (char*)textureData, w, h, 2, texture.mipmap()); case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: - return write16bX4TexelsGeneric((char*)pixels, (char*)textureData, w, h, 8, texture.GetMipmap()); + return write16bX4TexelsGeneric((char*)pixels, (char*)textureData, w, h, 8, texture.mipmap()); case CELL_GCM_TEXTURE_COMPRESSED_DXT1: case CELL_GCM_TEXTURE_COMPRESSED_DXT23: case CELL_GCM_TEXTURE_COMPRESSED_DXT45: - return writeCompressedTexel((char*)pixels, (char*)textureData, widthInBlocks, blockWidthInPixel, heightInBlocks, blockHeightInPixel, blockSizeInByte, texture.GetMipmap()); + return writeCompressedTexel((char*)pixels, (char*)textureData, widthInBlocks, blockWidthInPixel, heightInBlocks, blockHeightInPixel, blockSizeInByte, texture.mipmap()); default: - return writeTexelsGeneric((char*)pixels, (char*)textureData, w, h, blockSizeInByte, texture.GetMipmap()); + return writeTexelsGeneric((char*)pixels, (char*)textureData, w, h, blockSizeInByte, texture.mipmap()); } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index afbe88b704..4ed2981bfd 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -1,5 +1,4 @@ #pragma once -#ifdef DX12_SUPPORT #include "../RSXTexture.h" #include @@ -22,5 +21,4 @@ size_t getPlacedTextureStorageSpace(const rsx::texture &texture, size_t rowPitch * Data are not packed, they are stored per rows using rowPitchAlignement. * Similarly, offset for every mipmaplevel is aligned to rowPitchAlignement boundary. */ -std::vector uploadPlacedTexture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData); -#endif \ No newline at end of file +std::vector uploadPlacedTexture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData); \ No newline at end of file diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp index c9042de107..617a2da8cd 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.cpp @@ -92,25 +92,27 @@ DXGI_FORMAT getFormat(u8 type, u8 size) } static -std::vector getIALayout(ID3D12Device *device, const std::vector &vertexBufferFormat, const RSXVertexData *m_vertex_data, size_t baseOffset) +std::vector getIALayout(const rsx::data_array_format_info *vertex_info, const std::vector *vertex_data) { std::vector result; - for (size_t inputSlot = 0; inputSlot < vertexBufferFormat.size(); inputSlot++) + size_t inputSlot = 0; + for (size_t index = 0; index < rsx::limits::vertex_count; index++) { - for (size_t attributeId : vertexBufferFormat[inputSlot].attributeId) - { - const RSXVertexData &vertexData = m_vertex_data[attributeId]; + const auto &info = vertex_info[index]; + + if (!info.size) + continue; + D3D12_INPUT_ELEMENT_DESC IAElement = {}; IAElement.SemanticName = "TEXCOORD"; - IAElement.SemanticIndex = (UINT)attributeId; - IAElement.InputSlot = (UINT)inputSlot; - IAElement.Format = getFormat(vertexData.type - 1, vertexData.size); - IAElement.AlignedByteOffset = (UINT)(vertexData.addr + baseOffset - vertexBufferFormat[inputSlot].range.first); - IAElement.InputSlotClass = (vertexData.addr > 0) ? D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA : D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA; - IAElement.InstanceDataStepRate = (vertexData.addr > 0) ? 0 : 0; + IAElement.SemanticIndex = (UINT)index; + IAElement.InputSlot = (UINT)inputSlot++; + IAElement.Format = getFormat(info.type - 1, info.size); + IAElement.AlignedByteOffset = 0; + IAElement.InputSlotClass = info.array ? D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA : D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA; + IAElement.InstanceDataStepRate = 0; result.push_back(IAElement); - } } return result; } @@ -119,49 +121,42 @@ std::vector getIALayout(ID3D12Device *device, const st /** - * Suballocate a new vertex buffer with attributes from vbf using vertexIndexHeap as storage heap. + * */ static -D3D12_GPU_VIRTUAL_ADDRESS createVertexBuffer(const VertexBufferFormat &vbf, const RSXVertexData *vertexData, size_t baseOffset, ID3D12Device *device, DataHeap &vertexIndexHeap) +D3D12_GPU_VIRTUAL_ADDRESS createVertexBuffer(const rsx::data_array_format_info &vertex_array_desc, const std::vector &vertex_data, ID3D12Device *device, DataHeap &vertexIndexHeap) { - size_t subBufferSize = vbf.range.second - vbf.range.first + 1; - // Make multiple of stride - if (vbf.stride) - subBufferSize = ((subBufferSize + vbf.stride - 1) / vbf.stride) * vbf.stride; + size_t subBufferSize = vertex_data.size(); assert(vertexIndexHeap.canAlloc(subBufferSize)); size_t heapOffset = vertexIndexHeap.alloc(subBufferSize); void *buffer; ThrowIfFailed(vertexIndexHeap.m_heap->Map(0, &CD3DX12_RANGE(heapOffset, heapOffset + subBufferSize), (void**)&buffer)); void *bufferMap = (char*)buffer + heapOffset; - uploadVertexData(vbf, vertexData, baseOffset, bufferMap); + memcpy(bufferMap, vertex_data.data(), vertex_data.size()); vertexIndexHeap.m_heap->Unmap(0, &CD3DX12_RANGE(heapOffset, heapOffset + subBufferSize)); return vertexIndexHeap.m_heap->GetGPUVirtualAddress() + heapOffset; } std::vector D3D12GSRender::UploadVertexBuffers(bool indexed_draw) { + u32 m_vertex_data_base_offset = rsx::method_registers[NV4097_SET_VERTEX_DATA_BASE_OFFSET]; std::vector result; - const std::vector &vertexBufferFormat = FormatVertexData(m_vertex_data, m_vertexBufferSize, m_vertex_data_base_offset); - m_IASet = getIALayout(m_device.Get(), vertexBufferFormat, m_vertex_data, m_vertex_data_base_offset); + m_IASet = getIALayout(vertex_arrays_info, vertex_arrays); - const u32 data_offset = indexed_draw ? 0 : m_draw_array_first; - - for (size_t buffer = 0; buffer < vertexBufferFormat.size(); buffer++) + for (int index = 0; index < rsx::limits::vertex_count; ++index) { - const VertexBufferFormat &vbf = vertexBufferFormat[buffer]; - // Make multiple of stride - size_t subBufferSize = vbf.range.second - vbf.range.first + 1; - if (vbf.stride) - subBufferSize = ((subBufferSize + vbf.stride - 1) / vbf.stride) * vbf.stride; + const auto &info = vertex_arrays_info[index]; - D3D12_GPU_VIRTUAL_ADDRESS virtualAddress = createVertexBuffer(vbf, m_vertex_data, m_vertex_data_base_offset, m_device.Get(), m_vertexIndexData); - m_timers.m_bufferUploadSize += subBufferSize; + if (!info.size) + continue; + + D3D12_GPU_VIRTUAL_ADDRESS virtualAddress = createVertexBuffer(info, vertex_arrays[index], m_device.Get(), m_vertexIndexData); D3D12_VERTEX_BUFFER_VIEW vertexBufferView = {}; vertexBufferView.BufferLocation = virtualAddress; - vertexBufferView.SizeInBytes = (UINT)subBufferSize; - vertexBufferView.StrideInBytes = (UINT)vbf.stride; + vertexBufferView.SizeInBytes = (UINT)vertex_arrays[index].size(); + vertexBufferView.StrideInBytes = (UINT)rsx::get_vertex_type_size(info.type) * info.size; result.push_back(vertexBufferView); } @@ -173,16 +168,18 @@ D3D12_INDEX_BUFFER_VIEW D3D12GSRender::uploadIndexBuffers(bool indexed_draw) D3D12_INDEX_BUFFER_VIEW indexBufferView = {}; // No need for index buffer - if (!indexed_draw && isNativePrimitiveMode(m_draw_mode)) + if (!indexed_draw && isNativePrimitiveMode(draw_mode)) { m_renderingInfo.m_indexed = false; - m_renderingInfo.m_count = m_draw_array_count; - m_renderingInfo.m_baseVertex = m_draw_array_first; + m_renderingInfo.m_count = vertex_draw_count; + m_renderingInfo.m_baseVertex = 0; return indexBufferView; } m_renderingInfo.m_indexed = true; + u32 indexed_type = rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4; + // Index type size_t indexSize; if (!indexed_draw) @@ -192,7 +189,7 @@ D3D12_INDEX_BUFFER_VIEW D3D12GSRender::uploadIndexBuffers(bool indexed_draw) } else { - switch (m_indexed_array.m_type) + switch (indexed_type) { default: abort(); case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16: @@ -207,11 +204,11 @@ D3D12_INDEX_BUFFER_VIEW D3D12GSRender::uploadIndexBuffers(bool indexed_draw) } // Index count - m_renderingInfo.m_count = getIndexCount(m_draw_mode, indexed_draw ? (u32)(m_indexed_array.m_data.size() / indexSize) : m_draw_array_count); + m_renderingInfo.m_count = getIndexCount(draw_mode, indexed_draw ? (u32)(vertex_index_array.size() / indexSize) : vertex_draw_count); // Base vertex - if (!indexed_draw && isNativePrimitiveMode(m_draw_mode)) - m_renderingInfo.m_baseVertex = m_draw_array_first; + if (!indexed_draw && isNativePrimitiveMode(draw_mode)) + m_renderingInfo.m_baseVertex = 0; else m_renderingInfo.m_baseVertex = 0; @@ -224,7 +221,7 @@ D3D12_INDEX_BUFFER_VIEW D3D12GSRender::uploadIndexBuffers(bool indexed_draw) void *buffer; ThrowIfFailed(m_vertexIndexData.m_heap->Map(0, &CD3DX12_RANGE(heapOffset, heapOffset + subBufferSize), (void**)&buffer)); void *bufferMap = (char*)buffer + heapOffset; - uploadIndexData(m_draw_mode, m_indexed_array.m_type, indexed_draw ? m_indexed_array.m_data.data() : nullptr, bufferMap, indexed_draw ? (u32)(m_indexed_array.m_data.size() / indexSize) : m_draw_array_count); + uploadIndexData(draw_mode, indexed_type, indexed_draw ? vertex_index_array.data() : nullptr, bufferMap, indexed_draw ? (u32)(vertex_index_array.size() / indexSize) : vertex_draw_count); m_vertexIndexData.m_heap->Unmap(0, &CD3DX12_RANGE(heapOffset, heapOffset + subBufferSize)); m_timers.m_bufferUploadSize += subBufferSize; indexBufferView.SizeInBytes = (UINT)subBufferSize; @@ -242,18 +239,21 @@ void D3D12GSRender::setScaleOffset() 0.0f, 0.0f, 0.0f, 1.0f }; + int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; + int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; + // Scale - scaleOffsetMat[0] *= (float&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 0)] / (m_surface_clip_w / 2.f); - scaleOffsetMat[5] *= (float&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 1)] / (m_surface_clip_h / 2.f); - scaleOffsetMat[10] = (float&)methodRegisters[NV4097_SET_VIEWPORT_SCALE + (0x4 * 2)]; + scaleOffsetMat[0] *= (float&)rsx::method_registers[NV4097_SET_VIEWPORT_SCALE] / (clip_w / 2.f); + scaleOffsetMat[5] *= (float&)rsx::method_registers[NV4097_SET_VIEWPORT_SCALE + 1] / (clip_h / 2.f); + scaleOffsetMat[10] = (float&)rsx::method_registers[NV4097_SET_VIEWPORT_SCALE + 2]; // Offset - scaleOffsetMat[3] = (float&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 0)] - (m_surface_clip_w / 2.f); - scaleOffsetMat[7] = -((float&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 1)] - (m_surface_clip_h / 2.f)); - scaleOffsetMat[11] = (float&)methodRegisters[NV4097_SET_VIEWPORT_OFFSET + (0x4 * 2)]; + scaleOffsetMat[3] = (float&)rsx::method_registers[NV4097_SET_VIEWPORT_OFFSET] - (clip_w / 2.f); + scaleOffsetMat[7] = -((float&)rsx::method_registers[NV4097_SET_VIEWPORT_OFFSET + 1] - (clip_h / 2.f)); + scaleOffsetMat[11] = (float&)rsx::method_registers[NV4097_SET_VIEWPORT_OFFSET + 2]; - scaleOffsetMat[3] /= m_surface_clip_w / 2.f; - scaleOffsetMat[7] /= m_surface_clip_h / 2.f; + scaleOffsetMat[3] /= clip_w / 2.f; + scaleOffsetMat[7] /= clip_h / 2.f; assert(m_constantsData.canAlloc(256)); size_t heapOffset = m_constantsData.alloc(256); @@ -263,9 +263,10 @@ void D3D12GSRender::setScaleOffset() void *scaleOffsetMap; ThrowIfFailed(m_constantsData.m_heap->Map(0, &CD3DX12_RANGE(heapOffset, heapOffset + 256), &scaleOffsetMap)); streamToBuffer((char*)scaleOffsetMap + heapOffset, scaleOffsetMat, 16 * sizeof(float)); - int isAlphaTested = m_set_alpha_test; + int isAlphaTested = !!(rsx::method_registers[NV4097_SET_ALPHA_TEST_ENABLE]); + float alpha_ref = (float&)rsx::method_registers[NV4097_SET_ALPHA_REF]; memcpy((char*)scaleOffsetMap + heapOffset + 16 * sizeof(float), &isAlphaTested, sizeof(int)); - memcpy((char*)scaleOffsetMap + heapOffset + 17 * sizeof(float), &m_alpha_ref, sizeof(float)); + memcpy((char*)scaleOffsetMap + heapOffset + 17 * sizeof(float), &alpha_ref, sizeof(float)); m_constantsData.m_heap->Unmap(0, &CD3DX12_RANGE(heapOffset, heapOffset + 256)); D3D12_CONSTANT_BUFFER_VIEW_DESC constantBufferViewDesc = {}; @@ -278,11 +279,8 @@ void D3D12GSRender::setScaleOffset() void D3D12GSRender::FillVertexShaderConstantsBuffer() { - for (const RSXTransformConstant& c : m_transform_constants) - { - size_t offset = c.id * 4 * sizeof(float); - m_vertexConstants[offset] = c; - } + for (const auto &entry : transform_constants) + local_transform_constants[entry.first] = entry.second; size_t bufferSize = 512 * 4 * sizeof(float); @@ -291,15 +289,15 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer() void *constantsBufferMap; ThrowIfFailed(m_constantsData.m_heap->Map(0, &CD3DX12_RANGE(heapOffset, heapOffset + bufferSize), &constantsBufferMap)); - for (const auto &vertexConstants : m_vertexConstants) + for (const auto &entry : local_transform_constants) { float data[4] = { - vertexConstants.second.x, - vertexConstants.second.y, - vertexConstants.second.z, - vertexConstants.second.w + entry.second.x, + entry.second.y, + entry.second.z, + entry.second.w }; - streamToBuffer((char*)constantsBufferMap + heapOffset + vertexConstants.first, data, 4 * sizeof(float)); + streamToBuffer((char*)constantsBufferMap + heapOffset + entry.first * 4 * sizeof(float), data, 4 * sizeof(float)); } m_constantsData.m_heap->Unmap(0, &CD3DX12_RANGE(heapOffset, heapOffset + bufferSize)); @@ -314,7 +312,7 @@ void D3D12GSRender::FillVertexShaderConstantsBuffer() void D3D12GSRender::FillPixelShaderConstantsBuffer() { // Get constant from fragment program - const std::vector &fragmentOffset = m_cachePSO.getFragmentConstantOffsetsCache(m_cur_fragment_prog); + const std::vector &fragmentOffset = m_cachePSO.getFragmentConstantOffsetsCache(&fragment_program); size_t bufferSize = fragmentOffset.size() * 4 * sizeof(float) + 1; // Multiple of 256 never 0 bufferSize = (bufferSize + 255) & ~255; @@ -331,22 +329,22 @@ void D3D12GSRender::FillPixelShaderConstantsBuffer() // Is it assigned by color register in command buffer ? // TODO : we loop every iteration, we might do better... bool isCommandBufferSetConstant = false; - for (const RSXTransformConstant& c : m_fragment_constants) +/* for (const auto& entry : fragment_constants) { - size_t fragmentId = c.id - m_cur_fragment_prog->offset; + size_t fragmentId = entry.first - fragment_program.offset; if (fragmentId == offsetInFP) { isCommandBufferSetConstant = true; - vector[0] = (u32&)c.x; - vector[1] = (u32&)c.y; - vector[2] = (u32&)c.z; - vector[3] = (u32&)c.w; + vector[0] = (u32&)entry.second.x; + vector[1] = (u32&)entry.second.y; + vector[2] = (u32&)entry.second.z; + vector[3] = (u32&)entry.second.w; break; } - } + }*/ if (!isCommandBufferSetConstant) { - auto data = vm::ptr::make(m_cur_fragment_prog->addr + (u32)offsetInFP); + auto data = vm::ps3::ptr::make(fragment_program.addr + (u32)offsetInFP); u32 c0 = (data[0] >> 16 | data[0] << 16); u32 c1 = (data[1] >> 16 | data[1] << 16); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.h b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.h index cb363e0f6d..b884b072a9 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Buffer.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Buffer.h @@ -4,6 +4,6 @@ #include "Emu/Memory/vm.h" #include "Emu/RSX/RSXThread.h" -std::vector getIALayout(ID3D12Device *device, bool indexedDraw, const RSXVertexData *vertexData); +std::vector getIALayout(ID3D12Device *device, bool indexedDraw, const rsx::data_array_format_info *vertexData); #endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index a2858fd9ee..4604aa4903 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -93,8 +93,7 @@ void D3D12GSRender::ResourceStorage::WaitAndClean() void D3D12GSRender::ResourceStorage::Release() { - for (auto tmp : m_dirtyTextures) - tmp->Release(); + m_dirtyTextures.clear(); // NOTE: Should be released only after gfx pipeline last command has been finished. CloseHandle(m_frameFinishedHandle); } @@ -167,9 +166,6 @@ D3D12GSRender::D3D12GSRender() g_descriptorStrideRTV = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); g_descriptorStrideSamplers = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); - DXGI_ADAPTER_DESC adaptaterDesc; - adaptater->GetDesc(&adaptaterDesc); - m_frame->title_message(adaptaterDesc.Description); // Create swap chain and put them in a descriptor heap as rendertarget DXGI_SWAP_CHAIN_DESC swapChain = {}; swapChain.BufferCount = 2; @@ -291,19 +287,31 @@ D3D12GSRender::~D3D12GSRender() ReleaseD2DStructures(); } -void D3D12GSRender::oninit_thread() -{ -} - void D3D12GSRender::onexit_thread() { } +bool D3D12GSRender::domethod(u32 cmd, u32 arg) +{ + switch (cmd) + { + case NV4097_CLEAR_SURFACE: + clear_surface(arg); + return true; + case NV4097_TEXTURE_READ_SEMAPHORE_RELEASE: + semaphore_PGRAPH_texture_read_release(label_addr + rsx::method_registers[NV4097_SET_SEMAPHORE_OFFSET], arg); + return true; + case NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE: + semaphore_PGRAPH_backend_release(label_addr + rsx::method_registers[NV4097_SET_SEMAPHORE_OFFSET], + (arg & 0xff00ff00) | ((arg & 0xff) << 16) | ((arg >> 16) & 0xff)); + return true;; + default: + return false; + } +} + void D3D12GSRender::clear_surface(u32 arg) { - if ((arg & 0xf3) == 0) - return; - std::chrono::time_point startDuration = std::chrono::system_clock::now(); std::chrono::time_point rttDurationStart = std::chrono::system_clock::now(); @@ -312,33 +320,30 @@ void D3D12GSRender::clear_surface(u32 arg) std::chrono::time_point rttDurationEnd = std::chrono::system_clock::now(); m_timers.m_rttDuration += std::chrono::duration_cast(rttDurationEnd - rttDurationStart).count(); - u32 scissor_horizontal = rsx::method_registers[NV4097_SET_SCISSOR_HORIZONTAL]; - u32 scissor_vertical = rsx::method_registers[NV4097_SET_SCISSOR_VERTICAL]; - u16 scissor_x = scissor_horizontal; - u16 scissor_w = scissor_horizontal >> 16; - u16 scissor_y = scissor_vertical; - u16 scissor_h = scissor_vertical >> 16; +/* if (m_set_color_mask) + { + glColorMask(m_color_mask_r, m_color_mask_g, m_color_mask_b, m_color_mask_a); + checkForGlError("glColorMask"); + } - D3D12_RECT scissor; - scissor.left = scissor_x; - scissor.top = scissor_y; - scissor.right = scissor_x + scissor_w; - scissor.bottom = scissor_y + scissor_h; + if (m_set_scissor_horizontal && m_set_scissor_vertical) + { + glScissor(m_scissor_x, m_scissor_y, m_scissor_w, m_scissor_h); + checkForGlError("glScissor"); + }*/ // TODO: Merge depth and stencil clear when possible if (arg & 0x1) { - u32 surface_depth_format = (rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7; - u32 max_depth_value = surface_depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff; u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8; - - getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, clear_depth / (float)max_depth_value, 0, 0, &scissor); + u32 max_depth_value = m_surface.depth_format == CELL_GCM_SURFACE_Z16 ? 0x0000ffff : 0x00ffffff; + getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, clear_depth / (float)max_depth_value, 0, 0, nullptr); } if (arg & 0x2) { u8 clear_stencil = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] & 0xff; - getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, clear_stencil, 0, &scissor); + getCurrentResourceStorage().m_commandList->ClearDepthStencilView(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_STENCIL, 0.f, clear_stencil, 0, nullptr); } if (arg & 0xF0) @@ -348,7 +353,6 @@ void D3D12GSRender::clear_surface(u32 arg) u8 clear_r = clear_color >> 16; u8 clear_g = clear_color >> 8; u8 clear_b = clear_color; - float clearColor[] = { clear_r / 255.0f, @@ -360,29 +364,29 @@ void D3D12GSRender::clear_surface(u32 arg) size_t g_RTTIncrement = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { - case CELL_GCM_SURFACE_TARGET_NONE: break; + case CELL_GCM_SURFACE_TARGET_NONE: break; - case CELL_GCM_SURFACE_TARGET_0: - case CELL_GCM_SURFACE_TARGET_1: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); - break; - case CELL_GCM_SURFACE_TARGET_MRT1: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, &scissor); - break; - case CELL_GCM_SURFACE_TARGET_MRT2: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, &scissor); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, &scissor); - break; - case CELL_GCM_SURFACE_TARGET_MRT3: - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, &scissor); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, &scissor); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, &scissor); - getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(3, g_descriptorStrideRTV), clearColor, 0, &scissor); - break; - default: - LOG_ERROR(RSX, "Bad surface color target: %d", color_target); + case CELL_GCM_SURFACE_TARGET_0: + case CELL_GCM_SURFACE_TARGET_1: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); + break; + case CELL_GCM_SURFACE_TARGET_MRT1: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, nullptr); + break; + case CELL_GCM_SURFACE_TARGET_MRT2: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, nullptr); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, nullptr); + break; + case CELL_GCM_SURFACE_TARGET_MRT3: + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()), clearColor, 0, nullptr); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(1, g_descriptorStrideRTV), clearColor, 0, nullptr); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(2, g_descriptorStrideRTV), clearColor, 0, nullptr); + getCurrentResourceStorage().m_commandList->ClearRenderTargetView(CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart()).Offset(3, g_descriptorStrideRTV), clearColor, 0, nullptr); + break; + default: + LOG_ERROR(RSX, "Bad surface color target: %d", color_target); } } @@ -398,23 +402,6 @@ void D3D12GSRender::clear_surface(u32 arg) } } -bool D3D12GSRender::domethod(u32 id, u32 arg) -{ - switch (id) - { - case NV4097_CLEAR_SURFACE: - clear_surface(arg); - return true; - - default: - return false; - } -} - -void D3D12GSRender::begin() -{ -} - void D3D12GSRender::end() { std::chrono::time_point startDuration = std::chrono::system_clock::now(); @@ -427,34 +414,7 @@ void D3D12GSRender::end() std::chrono::time_point vertexIndexDurationStart = std::chrono::system_clock::now(); - // Init vertex count - if (!vertex_index_array.empty()) - { - /* - for (u32 i = 0; i < rsx::limits::vertex_count; ++i) - { - if (!m_vertex_data[i].IsEnabled()) continue; - if (!m_vertex_data[i].addr) continue; - - const u32 tsize = m_vertex_data[i].GetTypeSize(); - m_vertexBufferSize[i] = (m_indexed_array.index_min + m_indexed_array.index_max - m_indexed_array.index_min + 1) * tsize * m_vertex_data[i].size; - } - */ - } - else - { - for (u32 i = 0; i < rsx::limits::vertex_count; ++i) - { - auto &info = vertex_arrays_info[i]; - if (info.size == 0) - continue; - - m_vertexBufferSize[i] = (draw_array_first + draw_array_count) * rsx::get_vertex_type_size(info.type) * info.size; - } - } - - - if (draw_array_count) + if (!vertex_index_array.empty() || vertex_draw_count) { const std::vector &vertexBufferViews = UploadVertexBuffers(!vertex_index_array.empty()); const D3D12_INDEX_BUFFER_VIEW &indexBufferView = uploadIndexBuffers(!vertex_index_array.empty()); @@ -582,18 +542,15 @@ void D3D12GSRender::end() getCurrentResourceStorage().m_commandList->OMSetRenderTargets((UINT)numRTT, &m_rtts.m_renderTargetsDescriptorsHeap->GetCPUDescriptorHandleForHeapStart(), true, &CD3DX12_CPU_DESCRIPTOR_HANDLE(m_rtts.m_depthStencilDescriptorHeap->GetCPUDescriptorHandleForHeapStart())); - u32 clip_horizontal = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL]; - u32 clip_vertical = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL]; - - u32 clip_width = clip_horizontal >> 16; - u32 clip_height = clip_vertical >> 16; + int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; + int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; D3D12_VIEWPORT viewport = { 0.f, 0.f, - (float)clip_width, - (float)clip_height, + (float)clip_w, + (float)clip_h, -1.f, 1.f }; @@ -603,8 +560,8 @@ void D3D12GSRender::end() { 0, 0, - (LONG)clip_width, - (LONG)clip_height, + (LONG)clip_w, + (LONG)clip_h, }; getCurrentResourceStorage().m_commandList->RSSetScissorRects(1, &box); @@ -645,6 +602,7 @@ void D3D12GSRender::end() else getCurrentResourceStorage().m_commandList->DrawInstanced((UINT)m_renderingInfo.m_count, 1, (UINT)m_renderingInfo.m_baseVertex, 0); + vertex_index_array.clear(); std::chrono::time_point endDuration = std::chrono::system_clock::now(); m_timers.m_drawCallDuration += std::chrono::duration_cast(endDuration - startDuration).count(); m_timers.m_drawCallCount++; @@ -655,6 +613,8 @@ void D3D12GSRender::end() m_commandQueueGraphic->ExecuteCommandLists(1, (ID3D12CommandList**)getCurrentResourceStorage().m_commandList.GetAddressOf()); getCurrentResourceStorage().setNewCommandList(); } + + thread::end(); } static bool @@ -687,11 +647,12 @@ void D3D12GSRender::flip(int buffer) size_t w = 0, h = 0, rowPitch = 0; size_t offset = 0; - if (false/*m_read_buffer*/) + if (false) { - u32 addr = rsx::get_address(gcm_buffers[gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL); - w = gcm_buffers[gcm_current_buffer].width; - h = gcm_buffers[gcm_current_buffer].height; + CellGcmDisplayInfo* buffers;// = vm::get_ptr(m_gcm_buffers_addr); + u32 addr = rsx::get_address(buffers[gcm_current_buffer].offset, CELL_GCM_LOCATION_LOCAL); + w = buffers[gcm_current_buffer].width; + h = buffers[gcm_current_buffer].height; u8 *src_buffer = vm::get_ptr(addr); rowPitch = align(w * 4, 256); @@ -835,8 +796,8 @@ void D3D12GSRender::flip(int buffer) storage.m_getPosUAVHeap = m_UAVHeap.getCurrentPutPosMinusOne(); // Flush + local_transform_constants.clear(); m_texturesRTTs.clear(); - m_vertexConstants.clear(); // Now get ready for next frame ResourceStorage &newStorage = getCurrentResourceStorage(); @@ -853,6 +814,7 @@ void D3D12GSRender::flip(int buffer) m_frame->flip(nullptr); + std::chrono::time_point flipEnd = std::chrono::system_clock::now(); m_timers.m_flipDuration += std::chrono::duration_cast(flipEnd - flipStart).count(); } @@ -882,15 +844,13 @@ D3D12GSRender::ResourceStorage& D3D12GSRender::getNonCurrentResourceStorage() ID3D12Resource * D3D12GSRender::writeColorBuffer(ID3D12Resource * RTT, ID3D12GraphicsCommandList * cmdlist) { + int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; + int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; ID3D12Resource *Result; - - u32 clip_width = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; - u32 clip_height = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; - - size_t w = clip_width, h = clip_height; + size_t w = clip_w, h = clip_h; DXGI_FORMAT dxgiFormat; size_t rowPitch; - switch (rsx::method_registers[NV4097_SET_SURFACE_FORMAT] & 0x1f) + switch (m_surface.color_format) { case CELL_GCM_SURFACE_A8R8G8B8: dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -937,17 +897,18 @@ void copyToCellRamAndRelease(void *dstAddress, ID3D12Resource *res, size_t dstPi res->Release(); } -void D3D12GSRender::semaphorePGRAPHTextureReadRelease(u32 offset, u32 value) +void D3D12GSRender::semaphore_PGRAPH_texture_read_release(u32 offset, u32 value) { - semaphorePGRAPHBackendRelease(offset, value); + semaphore_PGRAPH_backend_release(offset, value); } -void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) +void D3D12GSRender::semaphore_PGRAPH_backend_release(u32 offset, u32 value) { // Add all buffer write // Cell can't make any assumption about readyness of color/depth buffer // Except when a semaphore is written by RSX - + int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; + int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; ComPtr fence; ThrowIfFailed( @@ -956,33 +917,23 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) HANDLE handle = CreateEvent(0, FALSE, FALSE, 0); fence->SetEventOnCompletion(1, handle); - u32 clip_width = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; - u32 clip_height = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; - ComPtr writeDest, depthConverted; ComPtr descriptorHeap; - size_t depthRowPitch = clip_width; + size_t depthRowPitch = clip_w; depthRowPitch = (depthRowPitch + 255) & ~255; - u32 dma_color_a = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_A]; - u32 dma_color_b = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_B]; - u32 dma_color_c = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_C]; - u32 dma_color_d = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_D]; - u32 dma_z = rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]; + u32 m_context_dma_color_a = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_A]; + u32 m_context_dma_color_b = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_B]; + u32 m_context_dma_color_c = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_C]; + u32 m_context_dma_color_d = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_D]; + u32 m_context_dma_z = rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]; - u32 offset_color_a = rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET]; - u32 offset_color_b = rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET]; - u32 offset_color_c = rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET]; - u32 offset_color_d = rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET]; + bool needTransfer = (m_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) || + ((m_context_dma_color_a || m_context_dma_color_b || m_context_dma_color_c || m_context_dma_color_d) && Ini.GSDumpColorBuffers.GetValue()); - u32 offset_z = rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET]; - - bool needTransfer = (dma_z && Ini.GSDumpDepthBuffer.GetValue()) || - ((dma_color_a || dma_color_b || dma_color_c || dma_color_d) && Ini.GSDumpColorBuffers.GetValue()); - - if (dma_z && Ini.GSDumpDepthBuffer.GetValue()) + if (m_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) { - size_t sizeInByte = clip_width * clip_height * 2; + size_t sizeInByte = clip_w * clip_h * 2; assert(m_UAVHeap.canAlloc(sizeInByte)); size_t heapOffset = m_UAVHeap.alloc(sizeInByte); @@ -990,14 +941,14 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) m_device->CreatePlacedResource( m_UAVHeap.m_heap, heapOffset, - &CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_R8_UNORM, clip_width, clip_height, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS), + &CD3DX12_RESOURCE_DESC::Tex2D(DXGI_FORMAT_R8_UNORM, clip_w, clip_h, 1, 1, 1, 0, D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, nullptr, IID_PPV_ARGS(depthConverted.GetAddressOf()) ) ); - sizeInByte = depthRowPitch * clip_height; + sizeInByte = depthRowPitch * clip_h; assert(m_readbackResources.canAlloc(sizeInByte)); heapOffset = m_readbackResources.alloc(sizeInByte); @@ -1017,7 +968,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) m_device->CreateDescriptorHeap(&descriptorHeapDesc, IID_PPV_ARGS(descriptorHeap.GetAddressOf())) ); D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; - switch (u32 depth_format = ((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7)) + switch (m_surface.depth_format) { case 0: break; @@ -1028,7 +979,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS; break; default: - LOG_ERROR(RSX, "Bad depth format! (%d)", depth_format); + LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface.depth_format); assert(0); } srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; @@ -1049,7 +1000,7 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) getCurrentResourceStorage().m_commandList->SetComputeRootSignature(m_convertRootSignature); getCurrentResourceStorage().m_commandList->SetDescriptorHeaps(1, descriptorHeap.GetAddressOf()); getCurrentResourceStorage().m_commandList->SetComputeRootDescriptorTable(0, descriptorHeap->GetGPUDescriptorHandleForHeapStart()); - getCurrentResourceStorage().m_commandList->Dispatch(clip_width / 8, clip_height / 8, 1); + getCurrentResourceStorage().m_commandList->Dispatch(clip_w / 8, clip_h / 8, 1); D3D12_RESOURCE_BARRIER barriers[] = { @@ -1058,50 +1009,52 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) }; getCurrentResourceStorage().m_commandList->ResourceBarrier(2, barriers); getCurrentResourceStorage().m_commandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(depthConverted.Get(), D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_COPY_SOURCE)); - getCurrentResourceStorage().m_commandList->CopyTextureRegion(&CD3DX12_TEXTURE_COPY_LOCATION(writeDest.Get(), { 0, { DXGI_FORMAT_R8_UNORM, clip_width, clip_height, 1, (UINT)depthRowPitch } }), 0, 0, 0, + getCurrentResourceStorage().m_commandList->CopyTextureRegion(&CD3DX12_TEXTURE_COPY_LOCATION(writeDest.Get(), { 0, { DXGI_FORMAT_R8_UNORM, (UINT)clip_w, (UINT)clip_h, 1, (UINT)depthRowPitch } }), 0, 0, 0, &CD3DX12_TEXTURE_COPY_LOCATION(depthConverted.Get(), 0), nullptr); - invalidateTexture(rsx::get_address(offset_z, dma_z - 0xfeed0000)); } + + invalidateAddress(rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], m_context_dma_z - 0xfeed0000)); + } ID3D12Resource *rtt0, *rtt1, *rtt2, *rtt3; if (Ini.GSDumpColorBuffers.GetValue()) { - switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) + switch (rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_NONE: break; case CELL_GCM_SURFACE_TARGET_0: - if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_1: - if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_MRT1: - if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); - if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_MRT2: - if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); - if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); - if (dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); break; case CELL_GCM_SURFACE_TARGET_MRT3: - if (dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); - if (dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); - if (dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); - if (dma_color_d) rtt3 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[3], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_a) rtt0 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[0], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_b) rtt1 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[1], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_c) rtt2 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[2], getCurrentResourceStorage().m_commandList.Get()); + if (m_context_dma_color_d) rtt3 = writeColorBuffer(m_rtts.m_currentlyBoundRenderTargets[3], getCurrentResourceStorage().m_commandList.Get()); break; } - if (dma_color_a) invalidateTexture(rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000)); - if (dma_color_b) invalidateTexture(rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000)); - if (dma_color_c) invalidateTexture(rsx::get_address(offset_color_c, dma_color_c - 0xfeed0000)); - if (dma_color_d) invalidateTexture(rsx::get_address(offset_color_d, dma_color_d - 0xfeed0000)); - } + if (m_context_dma_color_a) invalidateAddress(rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET], m_context_dma_color_a - 0xfeed0000)); + if (m_context_dma_color_b) invalidateAddress(rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET], m_context_dma_color_b - 0xfeed0000)); + if (m_context_dma_color_c) invalidateAddress(rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET], m_context_dma_color_c - 0xfeed0000)); + if (m_context_dma_color_d) invalidateAddress(rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET], m_context_dma_color_d - 0xfeed0000)); + } if (needTransfer) { ThrowIfFailed(getCurrentResourceStorage().m_commandList->Close()); @@ -1114,117 +1067,102 @@ void D3D12GSRender::semaphorePGRAPHBackendRelease(u32 offset, u32 value) WaitForSingleObject(handle, INFINITE); CloseHandle(handle); - if (dma_z && Ini.GSDumpDepthBuffer.GetValue()) + if (m_context_dma_z && Ini.GSDumpDepthBuffer.GetValue()) { - u32 address = rsx::get_address(offset_z, dma_z - 0xfeed0000); + u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET], m_context_dma_z - 0xfeed0000); auto ptr = vm::get_ptr(address); char *ptrAsChar = (char*)ptr; unsigned char *writeDestPtr; ThrowIfFailed(writeDest->Map(0, nullptr, (void**)&writeDestPtr)); - for (unsigned row = 0; row < clip_height; row++) + for (unsigned row = 0; row < (unsigned)clip_h; row++) { - for (unsigned i = 0; i < clip_width; i++) + for (unsigned i = 0; i < (unsigned)clip_w; i++) { unsigned char c = writeDestPtr[row * depthRowPitch + i]; - ptrAsChar[4 * (row * clip_width + i)] = c; - ptrAsChar[4 * (row * clip_width + i) + 1] = c; - ptrAsChar[4 * (row * clip_width + i) + 2] = c; - ptrAsChar[4 * (row * clip_width + i) + 3] = c; + ptrAsChar[4 * (row * clip_w + i)] = c; + ptrAsChar[4 * (row * clip_w + i) + 1] = c; + ptrAsChar[4 * (row * clip_w + i) + 2] = c; + ptrAsChar[4 * (row * clip_w + i) + 3] = c; } } } size_t srcPitch, dstPitch; - switch (rsx::method_registers[NV4097_SET_SURFACE_FORMAT] & 0x1f) + switch (m_surface.color_format) { case CELL_GCM_SURFACE_A8R8G8B8: - srcPitch = align(clip_width * 4, 256); - dstPitch = clip_width * 4; + srcPitch = align(clip_w * 4, 256); + dstPitch = clip_w * 4; break; case CELL_GCM_SURFACE_F_W16Z16Y16X16: - srcPitch = align(clip_width * 8, 256); - dstPitch = clip_width * 8; + srcPitch = align(clip_w * 8, 256); + dstPitch = clip_w * 8; break; } if (Ini.GSDumpColorBuffers.GetValue()) { - switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) + switch (rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_NONE: break; case CELL_GCM_SURFACE_TARGET_0: { - u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET], m_context_dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_w, clip_h); } break; case CELL_GCM_SURFACE_TARGET_1: { - u32 address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); + u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET], m_context_dma_color_b - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_w, clip_h); } break; case CELL_GCM_SURFACE_TARGET_MRT1: { - u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET], m_context_dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); - address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_w, clip_h); + address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET], m_context_dma_color_b - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_w, clip_h); } break; case CELL_GCM_SURFACE_TARGET_MRT2: { - u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET], m_context_dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); - address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_w, clip_h); + address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET], m_context_dma_color_b - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); - address = rsx::get_address(offset_color_c, dma_color_c - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_w, clip_h); + address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET], m_context_dma_color_c - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, clip_width, clip_height); + copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, clip_w, clip_h); } break; case CELL_GCM_SURFACE_TARGET_MRT3: { - u32 address = rsx::get_address(offset_color_a, dma_color_a - 0xfeed0000); + u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET], m_context_dma_color_a - 0xfeed0000); void *dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_width, clip_height); - address = rsx::get_address(offset_color_b, dma_color_b - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt0, srcPitch, dstPitch, clip_w, clip_h); + address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET], m_context_dma_color_b - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_width, clip_height); - address = rsx::get_address(offset_color_c, dma_color_c - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt1, srcPitch, dstPitch, clip_w, clip_h); + address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET], m_context_dma_color_c - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, clip_width, clip_height); - address = rsx::get_address(offset_color_d, dma_color_d - 0xfeed0000); + copyToCellRamAndRelease(dstAddress, rtt2, srcPitch, dstPitch, clip_w, clip_h); + address = rsx::get_address(rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET], m_context_dma_color_d - 0xfeed0000); dstAddress = vm::get_ptr(address); - copyToCellRamAndRelease(dstAddress, rtt3, srcPitch, dstPitch, clip_width, clip_height); + copyToCellRamAndRelease(dstAddress, rtt3, srcPitch, dstPitch, clip_w, clip_h); } break; } } - vm::ps3::write32(label_addr + offset, value); -} - -void D3D12GSRender::semaphorePFIFOAcquire(u32 offset, u32 value) -{ - const std::chrono::time_point enterWait = std::chrono::system_clock::now(); - while (true) - { - volatile u32 val = vm::ps3::read32(label_addr + offset); - if (val == value) break; - std::chrono::time_point waitPoint = std::chrono::system_clock::now(); - long long elapsedTime = std::chrono::duration_cast(waitPoint - enterWait).count(); - if (elapsedTime > 0) - LOG_ERROR(RSX, "Has wait for more than a second for semaphore acquire"); - std::this_thread::yield(); - } + vm::ps3::write32(offset, value); } #endif diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index d9ca443962..12957c1485 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -310,10 +310,12 @@ private: // Copy of RTT to be used as texture std::unordered_map m_texturesRTTs; + rsx::surface_info m_surface; + + RSXFragmentProgram fragment_program; PipelineStateObjectCache m_cachePSO; std::pair *m_PSO; - - size_t m_vertexBufferSize[32]; + std::unordered_map local_transform_constants; struct { @@ -451,18 +453,11 @@ public: u32 m_draw_frames; u32 m_skip_frames; - std::unordered_map m_vertexConstants; - D3D12GSRender(); virtual ~D3D12GSRender(); - void semaphorePGRAPHTextureReadRelease(u32 offset, u32 value); - void semaphorePGRAPHBackendRelease(u32 offset, u32 value); - void semaphorePFIFOAcquire(u32 offset, u32 value); - void notifyProgramChange(); - void notifyBlendStateChange(); - void notifyDepthStencilStateChange(); - void notifyRasterizerStateChange(); + void semaphore_PGRAPH_texture_read_release(u32 offset, u32 value); + void semaphore_PGRAPH_backend_release(u32 offset, u32 value); private: void InitD2DStructures(); @@ -512,16 +507,10 @@ private: void clear_surface(u32 arg); protected: - void begin() override; - void end() override; - - void oninit_thread() override; - void onexit_thread() override; - bool domethod(u32 id, u32 arg) override; - void flip(int buffer) override; - - //TODO - //u64 timestamp() const override; + virtual void onexit_thread() override; + virtual bool domethod(u32 cmd, u32 arg) override; + virtual void end() override; + virtual void flip(int buffer) override; }; #endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp index 4cf6f0529c..69a8d45c3a 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.cpp @@ -33,44 +33,31 @@ void Shader::Compile(const std::string &code, SHADER_TYPE st) } } -void D3D12GSRender::notifyProgramChange() -{ - m_PSO = nullptr; -} -void D3D12GSRender::notifyBlendStateChange() -{ - m_PSO = nullptr; -} -void D3D12GSRender::notifyDepthStencilStateChange() -{ - m_PSO = nullptr; -} -void D3D12GSRender::notifyRasterizerStateChange() -{ - m_PSO = nullptr; -} - bool D3D12GSRender::LoadProgram() { - if (m_PSO != nullptr) - return true; + RSXVertexProgram vertex_program; + u32 transform_program_start = rsx::method_registers[NV4097_SET_TRANSFORM_PROGRAM_START]; + vertex_program.data.reserve((512 - transform_program_start) * 4); - if (!m_cur_fragment_prog) + for (int i = transform_program_start; i < 512; ++i) { - LOG_WARNING(RSX, "LoadProgram: m_cur_shader_prog == NULL"); - return false; + vertex_program.data.resize((i - transform_program_start) * 4 + 4); + memcpy(vertex_program.data.data() + (i - transform_program_start) * 4, transform_program + i * 4, 4 * sizeof(u32)); + + D3 d3; + d3.HEX = transform_program[i * 4 + 3]; + + if (d3.end) + break; } - m_cur_fragment_prog->ctrl = m_shader_ctrl; - - if (!m_cur_vertex_prog) - { - LOG_WARNING(RSX, "LoadProgram: m_cur_vertex_prog == NULL"); - return false; - } + u32 shader_program = rsx::method_registers[NV4097_SET_SHADER_PROGRAM]; + fragment_program.offset = shader_program & ~0x3; + fragment_program.addr = rsx::get_address(fragment_program.offset, (shader_program & 0x3) - 1); + fragment_program.ctrl = rsx::method_registers[NV4097_SET_SHADER_CONTROL]; D3D12PipelineProperties prop = {}; - switch (m_draw_mode - 1) + switch (draw_mode - 1) { case GL_POINTS: prop.Topology = D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; @@ -108,87 +95,81 @@ bool D3D12GSRender::LoadProgram() }; prop.Blend = CD3D12_BLEND_DESC; - if (m_set_blend) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE]) { prop.Blend.RenderTarget[0].BlendEnable = true; - if (m_set_blend_mrt1) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x2) prop.Blend.RenderTarget[1].BlendEnable = true; - if (m_set_blend_mrt2) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x4) prop.Blend.RenderTarget[2].BlendEnable = true; - if (m_set_blend_mrt3) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x8) prop.Blend.RenderTarget[3].BlendEnable = true; - } - if (m_set_blend_equation) - { - prop.Blend.RenderTarget[0].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[0].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[0].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[0].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); - if (m_set_blend_mrt1) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x2) { - prop.Blend.RenderTarget[1].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[1].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[1].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[1].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); } - if (m_set_blend_mrt2) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x4) { - prop.Blend.RenderTarget[2].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[2].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[2].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[2].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); } - if (m_set_blend_mrt3) + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x8) { - prop.Blend.RenderTarget[3].BlendOp = getBlendOp(m_blend_equation_rgb); - prop.Blend.RenderTarget[3].BlendOpAlpha = getBlendOp(m_blend_equation_alpha); + prop.Blend.RenderTarget[3].BlendOp = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] & 0xFFFF); + prop.Blend.RenderTarget[3].BlendOpAlpha = getBlendOp(rsx::method_registers[NV4097_SET_BLEND_EQUATION] >> 16); + } + + prop.Blend.RenderTarget[0].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[0].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[0].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[0].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); + + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x2) + { + prop.Blend.RenderTarget[1].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[1].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[1].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[1].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); + } + + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x4) + { + prop.Blend.RenderTarget[2].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[2].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[2].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[2].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); + } + + if (rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] & 0x8) + { + prop.Blend.RenderTarget[3].SrcBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[3].DestBlend = getBlendFactor(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] & 0xFFFF); + prop.Blend.RenderTarget[3].SrcBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_SFACTOR] >> 16); + prop.Blend.RenderTarget[3].DestBlendAlpha = getBlendFactorAlpha(rsx::method_registers[NV4097_SET_BLEND_FUNC_DFACTOR] >> 16); } } - if (m_set_blend_sfactor && m_set_blend_dfactor) - { - prop.Blend.RenderTarget[0].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[0].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[0].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[0].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); - - if (m_set_blend_mrt1) - { - prop.Blend.RenderTarget[1].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[1].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[1].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[1].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); - } - - if (m_set_blend_mrt2) - { - prop.Blend.RenderTarget[2].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[2].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[2].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[2].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); - } - - if (m_set_blend_mrt3) - { - prop.Blend.RenderTarget[3].SrcBlend = getBlendFactor(m_blend_sfactor_rgb); - prop.Blend.RenderTarget[3].DestBlend = getBlendFactor(m_blend_dfactor_rgb); - prop.Blend.RenderTarget[3].SrcBlendAlpha = getBlendFactorAlpha(m_blend_sfactor_alpha); - prop.Blend.RenderTarget[3].DestBlendAlpha = getBlendFactorAlpha(m_blend_dfactor_alpha); - } - } - - if (m_set_logic_op) + if (rsx::method_registers[NV4097_SET_LOGIC_OP_ENABLE]) { prop.Blend.RenderTarget[0].LogicOpEnable = true; - prop.Blend.RenderTarget[0].LogicOp = getLogicOp(m_logic_op); + prop.Blend.RenderTarget[0].LogicOp = getLogicOp(rsx::method_registers[NV4097_SET_LOGIC_OP]); } - if (m_set_blend_color) +// if (m_set_blend_color) { // glBlendColor(m_blend_color_r, m_blend_color_g, m_blend_color_b, m_blend_color_a); // checkForGlError("glBlendColor"); } - switch (m_surface_depth_format) + switch (m_surface.depth_format) { case 0: break; @@ -199,11 +180,11 @@ bool D3D12GSRender::LoadProgram() prop.DepthStencilFormat = DXGI_FORMAT_D24_UNORM_S8_UINT; break; default: - LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface_depth_format); + LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface.depth_format); assert(0); } - switch (m_surface_color_format) + switch (m_surface.color_format) { case CELL_GCM_SURFACE_A8R8G8B8: prop.RenderTargetsFormat = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -213,7 +194,7 @@ bool D3D12GSRender::LoadProgram() break; } - switch (m_surface_color_target) + switch (u32 color_target = rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_0: case CELL_GCM_SURFACE_TARGET_1: @@ -229,33 +210,33 @@ bool D3D12GSRender::LoadProgram() prop.numMRT = 4; break; default: - LOG_ERROR(RSX, "Bad surface color target: %d", m_surface_color_target); + LOG_ERROR(RSX, "Bad surface color target: %d", color_target); } - prop.DepthStencil.DepthEnable = m_set_depth_test; - prop.DepthStencil.DepthWriteMask = m_depth_mask ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; - prop.DepthStencil.DepthFunc = getCompareFunc(m_depth_func); - prop.DepthStencil.StencilEnable = m_set_stencil_test; - prop.DepthStencil.StencilReadMask = m_stencil_func_mask; - prop.DepthStencil.StencilWriteMask = m_stencil_mask; - prop.DepthStencil.FrontFace.StencilPassOp = getStencilOp(m_stencil_zpass); - prop.DepthStencil.FrontFace.StencilDepthFailOp = getStencilOp(m_stencil_zfail); - prop.DepthStencil.FrontFace.StencilFailOp = getStencilOp(m_stencil_fail); - prop.DepthStencil.FrontFace.StencilFunc = getCompareFunc(m_stencil_func); + prop.DepthStencil.DepthEnable = !!(rsx::method_registers[NV4097_SET_DEPTH_TEST_ENABLE]); + prop.DepthStencil.DepthWriteMask = !!(rsx::method_registers[NV4097_SET_DEPTH_MASK]) ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO; + prop.DepthStencil.DepthFunc = getCompareFunc(rsx::method_registers[NV4097_SET_DEPTH_FUNC]); + prop.DepthStencil.StencilEnable = !!(rsx::method_registers[NV4097_SET_STENCIL_TEST_ENABLE]); + prop.DepthStencil.StencilReadMask = rsx::method_registers[NV4097_SET_STENCIL_FUNC_MASK]; + prop.DepthStencil.StencilWriteMask = rsx::method_registers[NV4097_SET_STENCIL_MASK]; + prop.DepthStencil.FrontFace.StencilPassOp = getStencilOp(rsx::method_registers[NV4097_SET_STENCIL_OP_ZPASS]); + prop.DepthStencil.FrontFace.StencilDepthFailOp = getStencilOp(rsx::method_registers[NV4097_SET_STENCIL_OP_ZFAIL]); + prop.DepthStencil.FrontFace.StencilFailOp = getStencilOp(rsx::method_registers[NV4097_SET_STENCIL_OP_FAIL]); + prop.DepthStencil.FrontFace.StencilFunc = getCompareFunc(rsx::method_registers[NV4097_SET_STENCIL_FUNC]); - if (m_set_two_sided_stencil_test_enable) + if (rsx::method_registers[NV4097_SET_TWO_SIDED_STENCIL_TEST_ENABLE]) { - prop.DepthStencil.BackFace.StencilFailOp = getStencilOp(m_back_stencil_fail); - prop.DepthStencil.BackFace.StencilFunc = getCompareFunc(m_back_stencil_func); - prop.DepthStencil.BackFace.StencilPassOp = getStencilOp(m_back_stencil_zpass); - prop.DepthStencil.BackFace.StencilDepthFailOp = getStencilOp(m_back_stencil_zfail); + prop.DepthStencil.BackFace.StencilFailOp = getStencilOp(rsx::method_registers[NV4097_SET_BACK_STENCIL_OP_FAIL]); + prop.DepthStencil.BackFace.StencilFunc = getCompareFunc(rsx::method_registers[NV4097_SET_BACK_STENCIL_FUNC]); + prop.DepthStencil.BackFace.StencilPassOp = getStencilOp(rsx::method_registers[NV4097_SET_BACK_STENCIL_OP_ZPASS]); + prop.DepthStencil.BackFace.StencilDepthFailOp = getStencilOp(rsx::method_registers[NV4097_SET_BACK_STENCIL_OP_ZFAIL]); } else { - prop.DepthStencil.BackFace.StencilPassOp = getStencilOp(m_stencil_zpass); - prop.DepthStencil.BackFace.StencilDepthFailOp = getStencilOp(m_stencil_zfail); - prop.DepthStencil.BackFace.StencilFailOp = getStencilOp(m_stencil_fail); - prop.DepthStencil.BackFace.StencilFunc = getCompareFunc(m_stencil_func); + prop.DepthStencil.BackFace.StencilPassOp = getStencilOp(rsx::method_registers[NV4097_SET_STENCIL_OP_ZPASS]); + prop.DepthStencil.BackFace.StencilDepthFailOp = getStencilOp(rsx::method_registers[NV4097_SET_STENCIL_OP_ZFAIL]); + prop.DepthStencil.BackFace.StencilFailOp = getStencilOp(rsx::method_registers[NV4097_SET_STENCIL_OP_FAIL]); + prop.DepthStencil.BackFace.StencilFunc = getCompareFunc(rsx::method_registers[NV4097_SET_STENCIL_FUNC]); } // Sensible default value @@ -274,20 +255,25 @@ bool D3D12GSRender::LoadProgram() D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF, }; prop.Rasterization = CD3D12_RASTERIZER_DESC; - switch (m_set_cull_face) + if (rsx::method_registers[NV4097_SET_CULL_FACE_ENABLE]) { - case CELL_GCM_FRONT: - prop.Rasterization.CullMode = D3D12_CULL_MODE_FRONT; - break; - case CELL_GCM_BACK: - prop.Rasterization.CullMode = D3D12_CULL_MODE_BACK; - break; - default: - prop.Rasterization.CullMode = D3D12_CULL_MODE_NONE; - break; + switch (rsx::method_registers[NV4097_SET_CULL_FACE]) + { + case CELL_GCM_FRONT: + prop.Rasterization.CullMode = D3D12_CULL_MODE_FRONT; + break; + case CELL_GCM_BACK: + prop.Rasterization.CullMode = D3D12_CULL_MODE_BACK; + break; + default: + prop.Rasterization.CullMode = D3D12_CULL_MODE_NONE; + break; + } } + else + prop.Rasterization.CullMode = D3D12_CULL_MODE_NONE; - switch (m_front_face) + switch (rsx::method_registers[NV4097_SET_FRONT_FACE]) { case CELL_GCM_CW: prop.Rasterization.FrontCounterClockwise = FALSE; @@ -297,20 +283,17 @@ bool D3D12GSRender::LoadProgram() break; } - if (m_set_color_mask) - { - UINT8 mask = 0; - mask |= m_color_mask_r ? D3D12_COLOR_WRITE_ENABLE_RED : 0; - mask |= m_color_mask_g ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0; - mask |= m_color_mask_b ? D3D12_COLOR_WRITE_ENABLE_BLUE : 0; - mask |= m_color_mask_a ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0; - for (unsigned i = 0; i < prop.numMRT; i++) - prop.Blend.RenderTarget[i].RenderTargetWriteMask = mask; - } + UINT8 mask = 0; + mask |= (rsx::method_registers[NV4097_SET_COLOR_MASK] >> 16) & 0xFF ? D3D12_COLOR_WRITE_ENABLE_RED : 0; + mask |= (rsx::method_registers[NV4097_SET_COLOR_MASK] >> 8) & 0xFF ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0; + mask |= rsx::method_registers[NV4097_SET_COLOR_MASK] & 0xFF ? D3D12_COLOR_WRITE_ENABLE_BLUE : 0; + mask |= (rsx::method_registers[NV4097_SET_COLOR_MASK] >> 24) & 0xFF ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0; + for (unsigned i = 0; i < prop.numMRT; i++) + prop.Blend.RenderTarget[i].RenderTargetWriteMask = mask; prop.IASet = m_IASet; - m_PSO = m_cachePSO.getGraphicPipelineState(m_cur_vertex_prog, m_cur_fragment_prog, prop, std::make_pair(m_device.Get(), m_rootSignatures)); + m_PSO = m_cachePSO.getGraphicPipelineState(&vertex_program, &fragment_program, prop, std::make_pair(m_device.Get(), m_rootSignatures)); return m_PSO != nullptr; } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 5fc125835e..80de73e65d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -14,26 +14,49 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist) { + u32 surface_format = rsx::method_registers[NV4097_SET_SURFACE_FORMAT]; + + u32 clip_horizontal = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL]; + u32 clip_vertical = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL]; + + u32 clip_width = clip_horizontal >> 16; + u32 clip_height = clip_vertical >> 16; + u32 clip_x = clip_horizontal; + u32 clip_y = clip_vertical; + + if (m_surface.format != surface_format) + { + m_surface.unpack(surface_format); + m_surface.width = clip_width; + m_surface.height = clip_height; + } + // Exit early if there is no rtt changes - if ((m_previous_address_a == m_surface_offset_a) && - (m_previous_address_b == m_surface_offset_b) && - (m_previous_address_c == m_surface_offset_c) && - (m_previous_address_d == m_surface_offset_d) && - (m_previous_address_z == m_surface_offset_z)) + if ((m_previous_address_a == rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET]) && + (m_previous_address_b == rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET]) && + (m_previous_address_c == rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET]) && + (m_previous_address_d == rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET]) && + (m_previous_address_z == rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET])) return; - m_previous_address_a = m_surface_offset_a; - m_previous_address_b = m_surface_offset_b; - m_previous_address_c = m_surface_offset_c; - m_previous_address_d = m_surface_offset_d; - m_previous_address_z = m_surface_offset_z; + m_previous_address_a = rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET]; + m_previous_address_b = rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET]; + m_previous_address_c = rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET]; + m_previous_address_d = rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET]; + m_previous_address_z = rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET]; + + u32 m_context_dma_color_a = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_A]; + u32 m_context_dma_color_b = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_B]; + u32 m_context_dma_color_c = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_C]; + u32 m_context_dma_color_d = rsx::method_registers[NV4097_SET_CONTEXT_DMA_COLOR_D]; + u32 m_context_dma_z = rsx::method_registers[NV4097_SET_CONTEXT_DMA_ZETA]; // FBO location has changed, previous data might be copied - u32 address_a = m_set_context_dma_color_a ? rsx::get_address(m_surface_offset_a, m_context_dma_color_a - 0xfeed0000) : 0; - u32 address_b = m_set_context_dma_color_b ? rsx::get_address(m_surface_offset_b, m_context_dma_color_b - 0xfeed0000) : 0; - u32 address_c = m_set_context_dma_color_c ? rsx::get_address(m_surface_offset_c, m_context_dma_color_c - 0xfeed0000) : 0; - u32 address_d = m_set_context_dma_color_d ? rsx::get_address(m_surface_offset_d, m_context_dma_color_d - 0xfeed0000) : 0; - u32 address_z = m_set_context_dma_z ? rsx::get_address(m_surface_offset_z, m_context_dma_z - 0xfeed0000) : 0; + u32 address_a = m_context_dma_color_a ? rsx::get_address(m_previous_address_a, m_context_dma_color_a - 0xfeed0000) : 0; + u32 address_b = m_context_dma_color_b ? rsx::get_address(m_previous_address_b, m_context_dma_color_b - 0xfeed0000) : 0; + u32 address_c = m_context_dma_color_c ? rsx::get_address(m_previous_address_c, m_context_dma_color_c - 0xfeed0000) : 0; + u32 address_d = m_context_dma_color_d ? rsx::get_address(m_previous_address_d, m_context_dma_color_d - 0xfeed0000) : 0; + u32 address_z = m_context_dma_z ? rsx::get_address(m_previous_address_z, m_context_dma_z - 0xfeed0000) : 0; // Make previous RTTs sampleable for (unsigned i = 0; i < 4; i++) @@ -56,7 +79,7 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist) size_t g_RTTIncrement = m_device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); DXGI_FORMAT dxgiFormat; - switch (m_surface_color_format) + switch (m_surface.color_format) { case CELL_GCM_SURFACE_A8R8G8B8: dxgiFormat = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -69,73 +92,86 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist) rttViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; rttViewDesc.Format = dxgiFormat; - switch (m_surface_color_target) + u32 clear_color = rsx::method_registers[NV4097_SET_COLOR_CLEAR_VALUE]; + u8 clear_a = clear_color >> 24; + u8 clear_r = clear_color >> 16; + u8 clear_g = clear_color >> 8; + u8 clear_b = clear_color; + std::array clearColor = + { + clear_r / 255.0f, + clear_g / 255.0f, + clear_b / 255.0f, + clear_a / 255.0f + }; + + switch (rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]) { case CELL_GCM_SURFACE_TARGET_0: { - ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle); break; } case CELL_GCM_SURFACE_TARGET_1: { - ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_b, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle); break; } case CELL_GCM_SURFACE_TARGET_MRT1: { - ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle); Handle.ptr += g_RTTIncrement; - ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle); } break; case CELL_GCM_SURFACE_TARGET_MRT2: { - ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle); Handle.ptr += g_RTTIncrement; - ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle); Handle.ptr += g_RTTIncrement; - ID3D12Resource *rttC = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 2, address_c, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttC = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 2, address_c, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttC, &rttViewDesc, Handle); break; } case CELL_GCM_SURFACE_TARGET_MRT3: { - ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttA = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 0, address_a, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttA, &rttViewDesc, Handle); Handle.ptr += g_RTTIncrement; - ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttB = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 1, address_b, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttB, &rttViewDesc, Handle); Handle.ptr += g_RTTIncrement; - ID3D12Resource *rttC = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 2, address_c, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttC = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 2, address_c, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttC, &rttViewDesc, Handle); Handle.ptr += g_RTTIncrement; - ID3D12Resource *rttD = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 3, address_d, m_surface_clip_w, m_surface_clip_h, m_surface_color_format, - m_clear_surface_color_r / 255.0f, m_clear_surface_color_g / 255.0f, m_clear_surface_color_b / 255.0f, m_clear_surface_color_a / 255.0f); + ID3D12Resource *rttD = m_rtts.bindAddressAsRenderTargets(m_device.Get(), copycmdlist, 3, address_d, clip_width, clip_height, m_surface.color_format, + clearColor); m_device->CreateRenderTargetView(rttD, &rttViewDesc, Handle); break; } } - ID3D12Resource *ds = m_rtts.bindAddressAsDepthStencil(m_device.Get(), copycmdlist, address_z, m_surface_clip_w, m_surface_clip_h, m_surface_depth_format, 1., 0); + ID3D12Resource *ds = m_rtts.bindAddressAsDepthStencil(m_device.Get(), copycmdlist, address_z, clip_width, clip_height, m_surface.depth_format, 1., 0); D3D12_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc = {}; - switch (m_surface_depth_format) + switch (m_surface.depth_format) { case 0: break; @@ -146,7 +182,7 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist) depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; break; default: - LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface_depth_format); + LOG_ERROR(RSX, "Bad depth format! (%d)", m_surface.depth_format); assert(0); } depthStencilViewDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D; @@ -154,7 +190,7 @@ void D3D12GSRender::PrepareRenderTargets(ID3D12GraphicsCommandList *copycmdlist) } ID3D12Resource *RenderTargets::bindAddressAsRenderTargets(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, size_t slot, u32 address, - size_t width, size_t height, u8 surfaceColorFormat, float clearColorR, float clearColorG, float clearColorB, float clearColorA) + size_t width, size_t height, u8 surfaceColorFormat, const std::array &clearColor) { ID3D12Resource* rtt; auto It = m_renderTargets.find(address); @@ -179,10 +215,10 @@ ID3D12Resource *RenderTargets::bindAddressAsRenderTargets(ID3D12Device *device, } D3D12_CLEAR_VALUE clearColorValue = {}; clearColorValue.Format = dxgiFormat; - clearColorValue.Color[0] = clearColorR; - clearColorValue.Color[1] = clearColorG; - clearColorValue.Color[2] = clearColorB; - clearColorValue.Color[3] = clearColorA; + clearColorValue.Color[0] = clearColor[0]; + clearColorValue.Color[1] = clearColor[1]; + clearColorValue.Color[2] = clearColor[2]; + clearColorValue.Color[3] = clearColor[3]; device->CreateCommittedResource( &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT), diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h index 719c189669..9341a70755 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.h @@ -20,7 +20,7 @@ struct RenderTargets * returns the corresponding render target resource. */ ID3D12Resource *bindAddressAsRenderTargets(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, size_t slot, u32 address, - size_t width, size_t height, u8 surfaceColorFormat, float clearColorR, float clearColorG, float clearColorB, float clearColorA); + size_t width, size_t height, u8 surfaceColorFormat, const std::array &clearColor); ID3D12Resource *bindAddressAsDepthStencil(ID3D12Device *device, ID3D12GraphicsCommandList *cmdList, u32 address, size_t width, size_t height, u8 surfaceDepthFormat, float depthClear, u8 stencilClear); diff --git a/rpcs3/Emu/RSX/GL/GLGSRender.cpp b/rpcs3/Emu/RSX/GL/GLGSRender.cpp index 3e1b7271f0..2c9d4bb525 100644 --- a/rpcs3/Emu/RSX/GL/GLGSRender.cpp +++ b/rpcs3/Emu/RSX/GL/GLGSRender.cpp @@ -1161,11 +1161,23 @@ void nv4097_clear_surface(u32 arg, GLGSRender* renderer) renderer->draw_fbo.clear((gl::buffers)mask); } +static void nv4097_texture_read_semaphore_release(u32 arg, GLGSRender* render) +{ + vm::ps3::write32(render->label_addr + rsx::method_registers[NV4097_SET_SEMAPHORE_OFFSET], arg); +} + +static void nv4097_backend_write_semaphore_release(u32 arg, GLGSRender* render) +{ + vm::ps3::write32(render->label_addr + rsx::method_registers[NV4097_SET_SEMAPHORE_OFFSET], (arg & 0xff00ff00) | ((arg & 0xff) << 16) | ((arg >> 16) & 0xff)); +} + using rsx_method_impl_t = void(*)(u32, GLGSRender*); static const std::unordered_map g_gl_method_tbl = { { NV4097_CLEAR_SURFACE, nv4097_clear_surface }, + { NV4097_TEXTURE_READ_SEMAPHORE_RELEASE, nv4097_texture_read_semaphore_release }, + { NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE, nv4097_backend_write_semaphore_release }, }; bool GLGSRender::domethod(u32 cmd, u32 arg) diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index eacc8d4950..3c0b143632 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -68,14 +68,13 @@ namespace rsx force_inline void texture_read_semaphore_release(thread* rsx, u32 arg) { //TODO: dma - vm::write32(rsx->label_addr + method_registers[NV4097_SET_SEMAPHORE_OFFSET], arg); + rsx->domethod(NV4097_TEXTURE_READ_SEMAPHORE_RELEASE, arg); } force_inline void back_end_write_semaphore_release(thread* rsx, u32 arg) { //TODO: dma - vm::write32(rsx->label_addr + method_registers[NV4097_SET_SEMAPHORE_OFFSET], - (arg & 0xff00ff00) | ((arg & 0xff) << 16) | ((arg >> 16) & 0xff)); + rsx->domethod(NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE, arg); } //fire only when all data passed to rsx cmd buffer @@ -119,19 +118,19 @@ namespace rsx template force_inline void set_vertex_data2f_m(thread* rsx, u32 arg) { - set_vertex_data_impl(rsx, arg); + set_vertex_data_impl(rsx, arg); } template force_inline void set_vertex_data3f_m(thread* rsx, u32 arg) { - set_vertex_data_impl(rsx, arg); + set_vertex_data_impl(rsx, arg); } template force_inline void set_vertex_data4f_m(thread* rsx, u32 arg) { - set_vertex_data_impl(rsx, arg); + set_vertex_data_impl(rsx, arg); } template diff --git a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp index 986f12d126..6d37b59f9e 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellResc.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellResc.cpp @@ -467,42 +467,39 @@ void InitMembers() void SetupRsxRenderingStates(vm::ptr& cntxt) { //TODO: use cntxt - /*GSRender& r = Emu.GetGSManager().GetRender(); - r.m_set_color_mask = true; r.m_color_mask_a = r.m_color_mask_r = r.m_color_mask_g = r.m_color_mask_b = true; - r.m_set_depth_mask = true; r.m_depth_mask = 0; - r.m_set_alpha_test = false; - r.m_set_blend = false; - r.m_set_blend_mrt1 = r.m_set_blend_mrt2 = r.m_set_blend_mrt3 = false; - r.m_set_logic_op = false; - r.m_set_cull_face = false; - r.m_set_depth_bounds_test = false; - r.m_set_depth_test = false; - r.m_set_poly_offset_fill = false; - r.m_set_stencil_test = false; - r.m_set_two_sided_stencil_test_enable = false; - r.m_set_two_side_light_enable = false; - r.m_set_point_sprite_control = false; - r.m_set_dither = true; - r.m_set_shade_mode = true; r.m_shade_mode = CELL_GCM_SMOOTH; - r.m_set_frequency_divider_operation = CELL_GCM_FREQUENCY_DIVIDE; + GSRender& r = Emu.GetGSManager().GetRender(); + rsx::method_registers[NV4097_SET_COLOR_MASK] = -1; + rsx::method_registers[NV4097_SET_DEPTH_MASK] = 0; + rsx::method_registers[NV4097_SET_ALPHA_TEST_ENABLE] = false; + rsx::method_registers[NV4097_SET_BLEND_ENABLE] = false; + rsx::method_registers[NV4097_SET_BLEND_ENABLE_MRT] = false; +// r.m_set_logic_op = false; + rsx::method_registers[NV4097_SET_CULL_FACE_ENABLE] = false; +// r.m_set_depth_bounds_test = false; + rsx::method_registers[NV4097_SET_DEPTH_TEST_ENABLE] = false; +// r.m_set_poly_offset_fill = false; +// r.m_set_stencil_test = false; +// r.m_set_two_sided_stencil_test_enable = false; +// r.m_set_two_side_light_enable = false; +// r.m_set_point_sprite_control = false; +// r.m_set_dither = true; +// r.m_set_shade_mode = true; r.m_shade_mode = CELL_GCM_SMOOTH; +// r.m_set_frequency_divider_operation = CELL_GCM_FREQUENCY_DIVIDE; - r.m_set_viewport_horizontal = r.m_set_viewport_vertical = true; - r.m_viewport_x = 0; - r.m_viewport_y = 0; - r.m_viewport_w = s_rescInternalInstance->m_dstWidth; - r.m_viewport_h = s_rescInternalInstance->m_dstHeight; + rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] = s_rescInternalInstance->m_dstWidth << 16; + rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] = s_rescInternalInstance->m_dstHeight << 16; - r.m_set_scissor_horizontal = r.m_set_scissor_vertical = true; - r.m_scissor_x = 0; - r.m_scissor_y = 0; - r.m_scissor_w = s_rescInternalInstance->m_dstWidth; - r.m_scissor_h = s_rescInternalInstance->m_dstHeight; +// r.m_set_scissor_horizontal = r.m_set_scissor_vertical = true; +// r.m_scissor_x = 0; +// r.m_scissor_y = 0; +// r.m_scissor_w = s_rescInternalInstance->m_dstWidth; +// r.m_scissor_h = s_rescInternalInstance->m_dstHeight; - r.m_width = s_rescInternalInstance->m_dstWidth; - r.m_height = s_rescInternalInstance->m_dstHeight; +// r.m_width = s_rescInternalInstance->m_dstWidth; +// r.m_height = s_rescInternalInstance->m_dstHeight; - r.m_surface_depth_format = 2; - r.m_surface_color_target = 1;*/ +// r.m_surface_depth_format = 2; + rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET] = 1; if (IsPalInterpolate()) { @@ -536,32 +533,32 @@ void SetupSurfaces(vm::ptr& cntxt) dstOffset1 = s_rescInternalInstance->m_dstOffsets[s_rescInternalInstance->m_bufIdPalMidNow]; } - //GSRender& r = Emu.GetGSManager().GetRender(); + GSRender& r = Emu.GetGSManager().GetRender(); - //r.m_surface_type = CELL_GCM_SURFACE_PITCH; - //r.m_surface_antialias = CELL_GCM_SURFACE_CENTER_1; - //r.m_surface_color_format = (u8)s_rescInternalInstance->m_pRescDsts->format; - //r.m_surface_color_target = (!isMrt) ? CELL_GCM_SURFACE_TARGET_0 : CELL_GCM_SURFACE_TARGET_MRT1; - ////surface.colorLocation[0] = CELL_GCM_LOCATION_LOCAL; - //r.m_surface_offset_a = dstOffset0; - //r.m_surface_pitch_a = s_rescInternalInstance->m_dstPitch; - ////surface.colorLocation[1] = CELL_GCM_LOCATION_LOCAL; - //r.m_surface_offset_b = (!isMrt) ? 0 : dstOffset1; - //r.m_surface_pitch_b = (!isMrt) ? 64 : s_rescInternalInstance->m_dstPitch; - ////surface.colorLocation[2] = CELL_GCM_LOCATION_LOCAL; - //r.m_surface_offset_c = 0; - //r.m_surface_pitch_c = 64; - ////surface.colorLocation[3] = CELL_GCM_LOCATION_LOCAL; - //r.m_surface_offset_d = 0; - //r.m_surface_pitch_d = 64; - //r.m_surface_depth_format = CELL_GCM_SURFACE_Z24S8; - ////surface.depthLocation = CELL_GCM_LOCATION_LOCAL; - //r.m_surface_offset_z = 0; - //r.m_surface_pitch_z = 64; - //r.m_surface_width = s_rescInternalInstance->m_dstWidth; - //r.m_surface_height = s_rescInternalInstance->m_dstHeight; - //r.m_surface_clip_x = 0; - //r.m_surface_clip_y = 0; +// r.m_surface_type = CELL_GCM_SURFACE_PITCH; +// r.m_surface_antialias = CELL_GCM_SURFACE_CENTER_1; +// r.m_surface_color_format = (u8)s_rescInternalInstance->m_pRescDsts->format; + rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET] = (!isMrt) ? CELL_GCM_SURFACE_TARGET_0 : CELL_GCM_SURFACE_TARGET_MRT1; + //surface.colorLocation[0] = CELL_GCM_LOCATION_LOCAL; + rsx::method_registers[NV4097_SET_SURFACE_COLOR_AOFFSET] = dstOffset0; + rsx::method_registers[NV4097_SET_SURFACE_PITCH_A] = s_rescInternalInstance->m_dstPitch; + //surface.colorLocation[1] = CELL_GCM_LOCATION_LOCAL; + rsx::method_registers[NV4097_SET_SURFACE_COLOR_BOFFSET] = (!isMrt) ? 0 : dstOffset1; + rsx::method_registers[NV4097_SET_SURFACE_PITCH_B] = (!isMrt) ? 64 : s_rescInternalInstance->m_dstPitch; + //surface.colorLocation[2] = CELL_GCM_LOCATION_LOCAL; + rsx::method_registers[NV4097_SET_SURFACE_COLOR_COFFSET] = 0; + rsx::method_registers[NV4097_SET_SURFACE_PITCH_C] = 64; + //surface.colorLocation[3] = CELL_GCM_LOCATION_LOCAL; + rsx::method_registers[NV4097_SET_SURFACE_COLOR_DOFFSET] = 0; + rsx::method_registers[NV4097_SET_SURFACE_PITCH_D] = 64; +// r.m_surface_depth_format = CELL_GCM_SURFACE_Z24S8; + //surface.depthLocation = CELL_GCM_LOCATION_LOCAL; + rsx::method_registers[NV4097_SET_SURFACE_ZETA_OFFSET]; + rsx::method_registers[NV4097_SET_SURFACE_PITCH_Z] = 64; +// r.m_surface_width = s_rescInternalInstance->m_dstWidth; +// r.m_surface_height = s_rescInternalInstance->m_dstHeight; +// r.m_surface_clip_x = 0; +// r.m_surface_clip_y = 0; } // Module<> Functions @@ -1142,7 +1139,7 @@ u16 FloatToHalf(float val) return ((s >> 16) & 0x8000) | ((e << 10) & 0x7c00) | ((m >> 13) & 0x03ff); } -static void blackman(float (&window)[4]) +static void blackman(float window[]) { const float x0 = ((1.f * 2.f*PI) / 5.f) - PI; const float x1 = ((2.f * 2.f*PI) / 5.f) - PI; diff --git a/rpcs3/Gui/RSXDebugger.cpp b/rpcs3/Gui/RSXDebugger.cpp index 09bcd33be9..06109561dd 100644 --- a/rpcs3/Gui/RSXDebugger.cpp +++ b/rpcs3/Gui/RSXDebugger.cpp @@ -11,7 +11,7 @@ #include "Emu/SysCalls/Modules/cellVideoOut.h" #include "Emu/RSX/GSManager.h" #include "Emu/RSX/GSRender.h" -//#include "Emu/RSX/GCM.h" +#include "Emu/RSX/GCM.h" #include "MemoryViewer.h" @@ -840,20 +840,8 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA auto args = vm::ps3::ptr::make(currentAddr + 4); u32 index = 0; - switch(cmd & 0x3ffff) + switch((cmd & 0x3ffff) >> 2) { - case NV406E_SEMAPHORE_OFFSET: - DISASM("PFIFO: Semaphore offset 0x%x", (u32)args[0]); - break; - - case NV406E_SEMAPHORE_ACQUIRE: - DISASM("PFIFO: Semaphore acquire at 0x%x", (u32)args[0]); - break; - - case NV406E_SEMAPHORE_RELEASE: - DISASM("PFIFO: Semaphore release value 0x%x", (u32)args[0]); - break; - case NV4097_SET_SURFACE_FORMAT: { const u32 a0 = (u32)args[0]; @@ -923,122 +911,6 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA } break; - case NV4097_SET_SURFACE_COLOR_TARGET: - DISASM("Set surface color target"); - break; - - case NV4097_SET_SHADER_WINDOW: - DISASM("Set shader windows"); - break; - - case NV4097_SET_DEPTH_TEST_ENABLE: - DISASM("Set depth test enable"); - break; - - case NV4097_SET_DEPTH_FUNC: - DISASM("Set depth func"); - break; - - case NV4097_SET_ZSTENCIL_CLEAR_VALUE: - DISASM("Set ZSTENCIL clear value"); - break; - - case NV4097_CLEAR_SURFACE: - DISASM("Clear surface"); - break; - - case NV4097_SET_TRANSFORM_CONSTANT_LOAD: - DISASM("Set transform constant load"); - break; - - case NV4097_SET_VERTEX_DATA_ARRAY_FORMAT: - DISASM("Set vertex data array format"); - break; - - case NV4097_SET_VERTEX_DATA_ARRAY_OFFSET: - DISASM("Set vertex data array offset"); - break; - - case NV4097_SET_SHADER_PROGRAM: - DISASM("Set shader program"); - break; - - case NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK: - DISASM("Set vertex attrib output mask"); - break; - - case NV4097_SET_TEX_COORD_CONTROL: - DISASM("Set tex coord control"); - break; - - case NV4097_SET_TRANSFORM_PROGRAM_LOAD: - DISASM("Set transform program load"); - break; - - case NV4097_SET_TRANSFORM_PROGRAM: - DISASM("Set transform program"); - break; - - case NV4097_SET_VERTEX_ATTRIB_INPUT_MASK: - DISASM("Set vertex attrib input mask"); - break; - - case NV4097_SET_TRANSFORM_TIMEOUT: - DISASM("Set transform timeout"); - break; - - case NV4097_INVALIDATE_VERTEX_CACHE_FILE: - DISASM("Invalidate vertex cache file"); - break; - - case NV4097_SET_SHADER_CONTROL: - DISASM("Set shader control"); - break; - - case NV4097_SET_SEMAPHORE_OFFSET: - DISASM("PGRAPH: Set semaphore offset 0x%x", (u32)args[0]); - break; - - case NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE: - DISASM("PGRAPH: Back end write semaphore release %x", (u32)args[0]); - break; - - case NV4097_SET_COLOR_MASK_MRT: - DISASM("Set color mask MRT"); - break; - - case NV4097_SET_TEXTURE_IMAGE_RECT: - DISASM("Set texture image rect"); - break; - - case NV4097_SET_TEXTURE_CONTROL3: - DISASM("Set texture control 3"); - break; - - case NV4097_SET_TEXTURE_CONTROL1: - DISASM("Set texture control 1"); - break; - - case NV4097_SET_TEXTURE_CONTROL0: - DISASM("Set texture control 0"); - break; - - case NV4097_SET_TEXTURE_ADDRESS: - DISASM("Set texture address"); - break; - - case NV4097_SET_TEXTURE_FILTER: - DISASM("Set texture filter"); - break; - - case NV4097_SET_BLEND_FUNC_SFACTOR: - DISASM("Set blend func sfactor"); - break; - - case NV4097_SET_FRONT_POLYGON_MODE: - DISASM("Set front polygon mode"); - break; - case NV4097_SET_VIEWPORT_HORIZONTAL: { u32 m_viewport_x = (u32)args[0] & 0xffff; @@ -1055,38 +927,6 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA break; } - case NV4097_SET_CLIP_MIN: - DISASM("Set clip min"); - break; - - case NV4097_SET_VIEWPORT_OFFSET: - DISASM("Set viewport offset"); - break; - - case NV4097_SET_SCISSOR_HORIZONTAL: - DISASM("Set scissor horizontal"); - break; - - case NV4097_INVALIDATE_L2: - DISASM("Invalidate L2"); - break; - - case NV4097_INVALIDATE_VERTEX_FILE: - DISASM("Invalidate vertex file"); - break; - - case NV4097_SET_BEGIN_END: - DISASM("Set BEGIN END"); - break; - - case NV4097_DRAW_ARRAYS: - DISASM("Draw arrays"); - break; - - case NV4097_SET_WINDOW_OFFSET: - DISASM("Set window offset"); - break; - case NV4097_SET_SURFACE_CLIP_HORIZONTAL: { const u32 a0 = (u32)args[0]; @@ -1116,10 +956,6 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA DISASM("NOP"); break; - case NV406E_SET_REFERENCE: - DISASM("Set reference: 0x%x", (u32)args[0]); - break; - case_16(NV4097_SET_TEXTURE_OFFSET, 0x20): DISASM("Texture Offset[%d]: %08x", index, (u32)args[0]); switch ((args[1] & 0x3) - 1) @@ -1154,38 +990,11 @@ wxString RSXDebugger::DisAsmCommand(u32 cmd, u32 count, u32 currentAddr, u32 ioA case NV4097_SET_DEPTH_BOUNDS_TEST_ENABLE: DISASM(args[0] ? "Depth bounds test: Enable" : "Depth bounds test: Disable"); break; - - case NV4097_SET_CONTEXT_DMA_COLOR_A: - DISASM("Context DMA Color A: 0x%x", (u32)args[0]); - break; - - case NV4097_SET_CONTEXT_DMA_COLOR_B: - DISASM("Context DMA Color B: 0x%x", (u32)args[0]); - break; - - case NV4097_SET_CONTEXT_DMA_COLOR_C: - DISASM("Context DMA Color C: 0x%x", (u32)args[0]); - if(count > 1) - DISASM("0x%x", (u32)args[1]); - break; - - case NV4097_SET_CONTEXT_DMA_ZETA: - DISASM("Context DMA Zeta: 0x%x", (u32)args[0]); - break; - - case NV4097_SET_SURFACE_PITCH_C: - DISASM("Surface Pitch C: 0x%x;", (u32)args[0]); - DISASM("Surface Pitch D: 0x%x;", (u32)args[1]); - DISASM("Surface Offset C: 0x%x;", (u32)args[2]); - DISASM("Surface Offset D: 0x%x", (u32)args[3]); - break; - - case NV4097_SET_SURFACE_PITCH_Z: - DISASM("Surface Pitch Z: 0x%x;", (u32)args[0]); - break; - default: - break; + { + std::string str = rsx::get_method_name((cmd & 0x3ffff) >> 2); + DISASM("%s : 0x%x", str.c_str(), (u32)args[0]); + } } if(cmd & CELL_GCM_METHOD_FLAG_NON_INCREMENT) diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 6f900dbdbc..9363293a30 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -60,8 +60,10 @@ + + @@ -532,9 +534,11 @@ + + @@ -770,55 +774,55 @@ - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) - .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include;..\glm + .\;..\;..\asmjit\src\asmjit;..\wxWidgets\include\msvc;..\wxWidgets\include;.\OpenAL\include;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;$(VC_IncludePath);$(WindowsSDK_IncludePath);..\llvm\include;..\llvm_build\include;$(UniversalCRT_IncludePath);..\minidx9\Include $(Platform)\$(Configuration)\emucore\ $(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ExcludePath) @@ -833,8 +837,7 @@ stdafx.h Async true - - + ../glm false @@ -851,8 +854,7 @@ stdafx.h Async true - - + ../glm false @@ -869,8 +871,7 @@ stdafx.h Async true - - + ../glm true @@ -890,8 +891,7 @@ stdafx.h Async true - - + ../glm true @@ -911,8 +911,7 @@ stdafx.h Async true - - + ../glm true @@ -929,8 +928,7 @@ stdafx.h Async true - - + ../glm _UNICODE;UNICODE;%(PreprocessorDefinitions) @@ -950,8 +948,7 @@ stdafx.h Async true - - + ../glm _UNICODE;UNICODE;DX12_SUPPORT;%(PreprocessorDefinitions) false @@ -973,8 +970,7 @@ Async LLVM_AVAILABLE;%(PreprocessorDefinitions) true - - + ../glm true @@ -998,8 +994,7 @@ Async LLVM_AVAILABLE;DX12_SUPPORT;%(PreprocessorDefinitions) true - - + ../glm false diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 4860f99fe3..e75f69456f 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -989,12 +989,18 @@ Utilities - - Emu\GPU\RSX\GL + + Emu\GPU\RSX\Common + + + Emu\GPU\RSX\Common Emu\GPU\RSX\Null + + Emu\GPU\RSX\GL + @@ -1888,11 +1894,17 @@ Emu\GPU\RSX\D3D12 - - Emu\GPU\RSX\GL + + Emu\GPU\RSX\Common + + + Emu\GPU\RSX\Common Utilities + + Emu\GPU\RSX\GL + \ No newline at end of file diff --git a/rpcs3/rpcs3.vcxproj b/rpcs3/rpcs3.vcxproj index 0cff6f4e59..62dc47eec5 100644 --- a/rpcs3/rpcs3.vcxproj +++ b/rpcs3/rpcs3.vcxproj @@ -139,38 +139,38 @@ - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\$(Configuration)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ProjectName)-dbg - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\Debug\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ProjectName)-dbg - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\Debug\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ProjectName)-dbg - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\Debug\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ProjectName)-dbg - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(UniversalCRT_IncludePath);$(IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(UniversalCRT_IncludePath);$(IncludePath) $(SolutionDir)bin\ ..\libs\Debug\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) $(ProjectName)-dbg false - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\$(Configuration)\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) false @@ -178,7 +178,7 @@ false - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\Release\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) false @@ -186,7 +186,7 @@ false - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\Release\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) false @@ -194,7 +194,7 @@ false - .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath);..\glm + .\;..\wxWidgets\include;..\SDL-1.3.0-5538\include;..\SDL_image-1.2.10;..\pthreads-2.8.0;..\;..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\Include;.\OpenAL\include;$(IncludePath);..\asmjit\src\asmjit;$(UniversalCRT_IncludePath) $(SolutionDir)bin\ ..\libs\Release\;$(UniversalCRT_LibraryPath_x64);$(LibraryPath) false @@ -206,7 +206,7 @@ Disabled ProgramDatabase Use - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm Async stdafx_gui.h $(IntDir)$(TargetName)_gui.pch @@ -236,7 +236,7 @@ Disabled ProgramDatabase Use - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm Async stdafx_gui.h $(IntDir)$(TargetName)_gui.pch @@ -266,7 +266,7 @@ Disabled ProgramDatabase Use - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm Async stdafx_gui.h $(IntDir)$(TargetName)_gui.pch @@ -296,7 +296,7 @@ Disabled ProgramDatabase Use - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm Async stdafx_gui.h $(IntDir)$(TargetName)_gui.pch @@ -326,7 +326,7 @@ Disabled ProgramDatabase Use - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm _UNICODE;UNICODE;MSVC_CRT_MEMLEAK_DETECTION;%(PreprocessorDefinitions);DX12_SUPPORT Async stdafx_gui.h @@ -356,7 +356,7 @@ Full true true - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm MultiThreadedDLL WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) false @@ -394,7 +394,7 @@ Full true true - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm MultiThreadedDLL WIN32;NDEBUG;_WINDOWS;LLVM_AVAILABLE;%(PreprocessorDefinitions) false @@ -432,7 +432,7 @@ Full true true - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm MultiThreadedDLL WIN32;NDEBUG;_WINDOWS;DX12_SUPPORT;%(PreprocessorDefinitions) false @@ -471,7 +471,7 @@ Full true true - ..\wxWidgets\include\msvc + ..\wxWidgets\include\msvc;..\glm MultiThreadedDLL WIN32;NDEBUG;_WINDOWS;LLVM_AVAILABLE;DX12_SUPPORT;%(PreprocessorDefinitions) false