mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-02 05:54:18 +01:00
bind default sampler
This commit is contained in:
parent
7ea18d8a5f
commit
35eea12950
@ -8,7 +8,7 @@ void CachedFBOMtl::CreateRenderPass()
|
|||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
auto& buffer = colorBuffer[i];
|
const auto& buffer = colorBuffer[i];
|
||||||
auto textureView = (LatteTextureViewMtl*)buffer.texture;
|
auto textureView = (LatteTextureViewMtl*)buffer.texture;
|
||||||
if (!textureView)
|
if (!textureView)
|
||||||
{
|
{
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "Cafe/HW/Latte/Core/FetchShader.h"
|
#include "Cafe/HW/Latte/Core/FetchShader.h"
|
||||||
#include "Cafe/HW/Latte/Core/LatteShader.h"
|
#include "Cafe/HW/Latte/Core/LatteShader.h"
|
||||||
#include "Cafe/HW/Latte/Core/LatteIndices.h"
|
#include "Cafe/HW/Latte/Core/LatteIndices.h"
|
||||||
|
#include "Metal/MTLSampler.hpp"
|
||||||
#include "Metal/MTLVertexDescriptor.hpp"
|
#include "Metal/MTLVertexDescriptor.hpp"
|
||||||
#include "gui/guiWrapper.h"
|
#include "gui/guiWrapper.h"
|
||||||
|
|
||||||
@ -21,6 +22,9 @@ MetalRenderer::MetalRenderer()
|
|||||||
m_device = MTL::CreateSystemDefaultDevice();
|
m_device = MTL::CreateSystemDefaultDevice();
|
||||||
m_commandQueue = m_device->newCommandQueue();
|
m_commandQueue = m_device->newCommandQueue();
|
||||||
|
|
||||||
|
MTL::SamplerDescriptor* samplerDescriptor = MTL::SamplerDescriptor::alloc()->init();
|
||||||
|
m_nearestSampler = m_device->newSamplerState(samplerDescriptor);
|
||||||
|
|
||||||
m_memoryManager = new MetalMemoryManager(this);
|
m_memoryManager = new MetalMemoryManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,6 +548,21 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
|
|||||||
renderPipelineDescriptor->setFragmentFunction(static_cast<RendererShaderMtl*>(pixelShader->shader)->GetFunction());
|
renderPipelineDescriptor->setFragmentFunction(static_cast<RendererShaderMtl*>(pixelShader->shader)->GetFunction());
|
||||||
// TODO: don't always set the vertex descriptor
|
// TODO: don't always set the vertex descriptor
|
||||||
renderPipelineDescriptor->setVertexDescriptor(vertexDescriptor);
|
renderPipelineDescriptor->setVertexDescriptor(vertexDescriptor);
|
||||||
|
for (uint8 i = 0; i < 8; i++)
|
||||||
|
{
|
||||||
|
const auto& colorBuffer = m_state.activeFBO->colorBuffer[i];
|
||||||
|
auto texture = static_cast<LatteTextureViewMtl*>(colorBuffer.texture);
|
||||||
|
if (!texture)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
renderPipelineDescriptor->colorAttachments()->object(i)->setPixelFormat(texture->GetTexture()->pixelFormat());
|
||||||
|
}
|
||||||
|
if (m_state.activeFBO->depthBuffer.texture)
|
||||||
|
{
|
||||||
|
auto texture = static_cast<LatteTextureViewMtl*>(m_state.activeFBO->depthBuffer.texture);
|
||||||
|
renderPipelineDescriptor->setDepthAttachmentPixelFormat(texture->GetTexture()->pixelFormat());
|
||||||
|
}
|
||||||
|
|
||||||
NS::Error* error = nullptr;
|
NS::Error* error = nullptr;
|
||||||
MTL::RenderPipelineState* renderPipelineState = m_device->newRenderPipelineState(renderPipelineDescriptor, &error);
|
MTL::RenderPipelineState* renderPipelineState = m_device->newRenderPipelineState(renderPipelineDescriptor, &error);
|
||||||
@ -579,8 +598,7 @@ void MetalRenderer::draw_execute(uint32 baseVertex, uint32 baseInstance, uint32
|
|||||||
if (vertexBufferRange.needsRebind)
|
if (vertexBufferRange.needsRebind)
|
||||||
{
|
{
|
||||||
m_renderCommandEncoder->setVertexBuffer(m_memoryManager->GetBufferCache(), vertexBufferRange.offset, GET_MTL_VERTEX_BUFFER_INDEX(i));
|
m_renderCommandEncoder->setVertexBuffer(m_memoryManager->GetBufferCache(), vertexBufferRange.offset, GET_MTL_VERTEX_BUFFER_INDEX(i));
|
||||||
// TODO: uncomment
|
vertexBufferRange.needsRebind = false;
|
||||||
//vertexBufferRange.needRebind = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,15 +658,31 @@ void MetalRenderer::BindStageResources(LatteDecompilerShader* shader)
|
|||||||
//auto imageViewObj = textureView->GetSamplerView(word4);
|
//auto imageViewObj = textureView->GetSamplerView(word4);
|
||||||
//info.imageView = imageViewObj->m_textureImageView;
|
//info.imageView = imageViewObj->m_textureImageView;
|
||||||
|
|
||||||
|
uint32 binding = shader->resourceMapping.getTextureBaseBindingPoint() + i;
|
||||||
|
|
||||||
uint32 stageSamplerIndex = shader->textureUnitSamplerAssignment[relative_textureUnit];
|
uint32 stageSamplerIndex = shader->textureUnitSamplerAssignment[relative_textureUnit];
|
||||||
// TODO: uncomment
|
// TODO: uncomment
|
||||||
MTL::SamplerState* sampler = nullptr;//basicSampler;
|
|
||||||
if (stageSamplerIndex != LATTE_DECOMPILER_SAMPLER_NONE)
|
if (stageSamplerIndex != LATTE_DECOMPILER_SAMPLER_NONE)
|
||||||
{
|
{
|
||||||
// TODO: bind the actual sampler
|
// TODO: bind the actual sampler
|
||||||
|
MTL::SamplerState* sampler = m_nearestSampler;
|
||||||
|
switch (shader->shaderType)
|
||||||
|
{
|
||||||
|
case LatteConst::ShaderType::Vertex:
|
||||||
|
{
|
||||||
|
m_renderCommandEncoder->setVertexSamplerState(sampler, binding);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case LatteConst::ShaderType::Pixel:
|
||||||
|
{
|
||||||
|
m_renderCommandEncoder->setFragmentSamplerState(sampler, binding);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
UNREACHABLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 binding = shader->resourceMapping.getTextureBaseBindingPoint() + i;
|
|
||||||
switch (shader->shaderType)
|
switch (shader->shaderType)
|
||||||
{
|
{
|
||||||
case LatteConst::ShaderType::Vertex:
|
case LatteConst::ShaderType::Vertex:
|
||||||
|
@ -186,6 +186,9 @@ private:
|
|||||||
MTL::Device* m_device;
|
MTL::Device* m_device;
|
||||||
MTL::CommandQueue* m_commandQueue;
|
MTL::CommandQueue* m_commandQueue;
|
||||||
|
|
||||||
|
// Basic
|
||||||
|
MTL::SamplerState* m_nearestSampler;
|
||||||
|
|
||||||
// Active objects
|
// Active objects
|
||||||
MTL::CommandBuffer* m_commandBuffer = nullptr;
|
MTL::CommandBuffer* m_commandBuffer = nullptr;
|
||||||
MTL::RenderCommandEncoder* m_renderCommandEncoder = nullptr;
|
MTL::RenderCommandEncoder* m_renderCommandEncoder = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user