浏览代码

Use RenderTextureDescriptor with CreateDepthStencilBuffer

Start using HDCamera.renderTextureDesc in new RenderTexture instances.  Does have support for width/height override in order to support HTile allocation.
/feature-ReflectionProbeFit
Robert Srinivasiah 7 年前
当前提交
26babfa7
共有 1 个文件被更改,包括 12 次插入17 次删除
  1. 29
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs

29
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


// TODO: We need to respect QualitySettings.activeColorSpace
RenderTexture CreateRenderTexture(HDCamera hdCamera, int depthBufferBits, RenderTextureFormat format, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default)
RenderTexture CreateRenderTexture(HDCamera hdCamera, int depthBufferBits, RenderTextureFormat format,
RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default,
int widthOverride = 0, int heightOverride = 0)
if (widthOverride > 0)
localDesc.width = widthOverride;
if (heightOverride > 0)
localDesc.height = heightOverride;
}
void CreateTemporaryRT(CommandBuffer cmd, int nameID, HDCamera hdCamera,

if (m_CameraDepthStencilBuffer != null)
m_CameraDepthStencilBuffer.Release();
m_CameraDepthStencilBuffer = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 24, RenderTextureFormat.Depth);
//m_CameraDepthStencilBuffer = CreateRenderTexture(hdCamera, 24, RenderTextureFormat.Depth);
m_CameraDepthStencilBuffer = CreateRenderTexture(hdCamera, 24, RenderTextureFormat.Depth);
m_CameraDepthStencilBuffer.filterMode = FilterMode.Point;
m_CameraDepthStencilBuffer.Create();
m_CameraDepthStencilBufferRT = new RenderTargetIdentifier(m_CameraDepthStencilBuffer);

if (m_CameraDepthBufferCopy != null)
m_CameraDepthBufferCopy.Release();
m_CameraDepthBufferCopy = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 24, RenderTextureFormat.Depth);
//m_CameraDepthBufferCopy = CreateRenderTexture(hdCamera, 24, RenderTextureFormat.Depth);
m_CameraDepthBufferCopy = CreateRenderTexture(hdCamera, 24, RenderTextureFormat.Depth);
m_CameraDepthBufferCopy.filterMode = FilterMode.Point;
m_CameraDepthBufferCopy.Create();
m_CameraDepthBufferCopyRT = new RenderTargetIdentifier(m_CameraDepthBufferCopy);

if (m_CameraStencilBufferCopy != null)
m_CameraStencilBufferCopy.Release();
m_CameraStencilBufferCopy = new RenderTexture(camera.pixelWidth, camera.pixelHeight, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
//m_CameraStencilBufferCopy = CreateRenderTexture(hdCamera, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_CameraStencilBufferCopy = CreateRenderTexture(hdCamera, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_CameraStencilBufferCopy.filterMode = FilterMode.Point;
m_CameraStencilBufferCopy.Create();
m_CameraStencilBufferCopyRT = new RenderTargetIdentifier(m_CameraStencilBufferCopy);

m_HTile.Release();
// We use 8x8 tiles in order to match the native GCN HTile as closely as possible.
m_HTile = new RenderTexture((camera.pixelWidth + 7) / 8, (camera.pixelHeight + 7) / 8, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
//var desc = hdCamera.renderTextureDesc;
//desc.width = (desc.width + 7) / 8;
//desc.height = (desc.height + 7) / 8;
//desc.depthBufferBits = 0;
//desc.colorFormat = RenderTextureFormat.R8;
//desc.sRGB = false;
//m_HTile = new RenderTexture((camera.pixelWidth + 7) / 8, (camera.pixelHeight + 7) / 8, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear); // DXGI_FORMAT_R8_UINT is not supported by Unity
var desc = hdCamera.renderTextureDesc;
m_HTile = CreateRenderTexture(hdCamera, 0, RenderTextureFormat.R8, RenderTextureReadWrite.Linear, ((desc.width + 7) / 8), ((desc.height + 7) / 8)); // DXGI_FORMAT_R8_UINT is not supported by Unity
m_HTile.filterMode = FilterMode.Point;
m_HTile.enableRandomWrite = true;
m_HTile.Create();

正在加载...
取消
保存