networking
This commit is contained in:
@@ -44,6 +44,8 @@ static uint32_t s_nNumAttachments;
|
||||
CUtlVector<MTL::Texture*> g_destroyImageBuffer;
|
||||
CUtlVector<MTL::Buffer*> g_destroyBuffersBuffer;
|
||||
|
||||
extern MTL::PixelFormat g_swapchainFormat;
|
||||
|
||||
MTL::PixelFormat IRenderer_FormatToMl( EImageFormat format )
|
||||
{
|
||||
switch (format)
|
||||
@@ -51,6 +53,7 @@ MTL::PixelFormat IRenderer_FormatToMl( EImageFormat format )
|
||||
case IMAGE_FORMAT_R8G8B8A8: return MTL::PixelFormatRGBA8Unorm;
|
||||
case IMAGE_FORMAT_R16G16B16A16: return MTL::PixelFormatRGBA16Unorm;
|
||||
case IMAGE_FORMAT_DEPTH: return MTL::PixelFormatDepth32Float;
|
||||
case IMAGE_FORMAT_WINDOW: return g_swapchainFormat;
|
||||
default: return MTL::PixelFormatRGBA8Unorm;
|
||||
}
|
||||
};
|
||||
@@ -294,6 +297,17 @@ void IRenderer::PushBindings()
|
||||
if (g_pCurrentPipeline->type == PIPELINE_TYPE_RASTERIZATION)
|
||||
{
|
||||
CMlGraphicsPipeline *pPipeline = (CMlGraphicsPipeline*)g_pCurrentPipeline;
|
||||
bool bHasTextures = false;
|
||||
for ( int i = 0; i < pPipeline->m_inputs.GetSize(); i++ )
|
||||
{
|
||||
if (pPipeline->m_inputs[i].type == SHADER_INPUT_TYPE_TEXTURES)
|
||||
{
|
||||
bHasTextures = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bHasTextures)
|
||||
return;
|
||||
|
||||
MTL::ArgumentEncoder *argumentEncoder = 0;
|
||||
for (auto &shader: pPipeline->m_shaders)
|
||||
@@ -345,7 +359,6 @@ void IRenderer::Begin( uint32_t nWidth, uint32_t nHeight, CUtlVector<RenderingCo
|
||||
}
|
||||
|
||||
s_pEncoder = g_mlCommandBuffer->renderCommandEncoder(s_pRenderPass);
|
||||
s_pEncoder->setCullMode(MTL::CullModeFront);
|
||||
}
|
||||
|
||||
void IRenderer::ResetState()
|
||||
@@ -355,7 +368,23 @@ void IRenderer::ResetState()
|
||||
|
||||
void IRenderer::SetDepthMode( EDepthMode mode )
|
||||
{
|
||||
|
||||
MTL::DepthStencilDescriptor* depthStencilDesc = MTL::DepthStencilDescriptor::alloc()->init();
|
||||
if (mode == DEPTH_MODE_DISABLED)
|
||||
{
|
||||
depthStencilDesc->setDepthWriteEnabled(false);
|
||||
} else {
|
||||
depthStencilDesc->setDepthWriteEnabled(true);
|
||||
switch (mode)
|
||||
{
|
||||
case DEPTH_MODE_LESS:
|
||||
depthStencilDesc->setDepthCompareFunction(MTL::CompareFunctionLess); break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
auto depthStencilState = g_mlDevice->newDepthStencilState(depthStencilDesc);
|
||||
s_pEncoder->setDepthStencilState(depthStencilState);
|
||||
depthStencilDesc->release();
|
||||
}
|
||||
|
||||
void IRenderer::Draw( IVertexBuffer *pVertex, IIndexBuffer *pIndex )
|
||||
@@ -366,11 +395,6 @@ void IRenderer::Draw( IVertexBuffer *pVertex, IIndexBuffer *pIndex )
|
||||
{
|
||||
|
||||
} else {
|
||||
MTL::DepthStencilDescriptor* depthStencilDesc = MTL::DepthStencilDescriptor::alloc()->init();
|
||||
depthStencilDesc->setDepthCompareFunction(MTL::CompareFunctionLess);
|
||||
depthStencilDesc->setDepthWriteEnabled(true);
|
||||
auto depthStencilState = g_mlDevice->newDepthStencilState(depthStencilDesc);
|
||||
s_pEncoder->setDepthStencilState(depthStencilState);
|
||||
|
||||
|
||||
CMlGraphicsPipeline *pPipeline = (CMlGraphicsPipeline*)g_pCurrentPipeline;
|
||||
@@ -389,8 +413,11 @@ IBuffer *IRenderer::GetCameraMatrix()
|
||||
return g_cameraProperties;
|
||||
}
|
||||
|
||||
static CMlImage *pOutputImage = new CMlImage;
|
||||
IImage *IRenderer::GetOutputImage()
|
||||
{
|
||||
pOutputImage->m_image = g_mlDrawableTexture;
|
||||
return pOutputImage;
|
||||
}
|
||||
|
||||
IGraphicsPipeline *IRenderer::CreateGraphicsPipeline(
|
||||
@@ -479,6 +506,9 @@ uint32_t ITextureManager::GetTextureID(ITexture *pTexture)
|
||||
ITexture *ITextureManager::LoadTexture( void *pData, uint32_t X, uint32_t Y, uint32_t numChannels )
|
||||
{
|
||||
CMlTexture *pTexture = new CMlTexture;
|
||||
*pTexture = {};
|
||||
pTexture->x = X;
|
||||
pTexture->y = Y;
|
||||
|
||||
MTL::TextureDescriptor *pCreateInfo = MTL::TextureDescriptor::alloc()->init();
|
||||
pCreateInfo->setPixelFormat(MTL::PixelFormatRGBA8Unorm_sRGB);
|
||||
@@ -588,7 +618,6 @@ void IMetal::Frame()
|
||||
glm_rotate(perspective, glm_rad(90), (vec4){1,0,0,0});
|
||||
glm_scale(perspective, (vec4){1,-1,1,1});
|
||||
glm_rotate(perspective, glm_rad(90), (vec4){0,0,1,0});
|
||||
glm_scale(perspective, (vec4){1,1,-1,1});
|
||||
glm_mat4_mul(perspective,g_cameraDataMap->viewprojection,g_cameraDataMap->viewprojection);
|
||||
|
||||
if (g_bConfigNotify)
|
||||
|
||||
Reference in New Issue
Block a user