From 4a79ac80393b628fb50154e24cbd7257a7eda992 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 28 Nov 2014 21:12:17 +0000 Subject: [PATCH] Move CalcNumMips to common header so GL code can access it --- renderdoc/common/common.cpp | 15 +++++++++++++++ renderdoc/common/common.h | 2 ++ renderdoc/driver/d3d11/d3d11_resources.cpp | 15 --------------- renderdoc/driver/d3d11/d3d11_resources.h | 2 -- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/renderdoc/common/common.cpp b/renderdoc/common/common.cpp index 10d1542a1..644bdb181 100644 --- a/renderdoc/common/common.cpp +++ b/renderdoc/common/common.cpp @@ -223,6 +223,21 @@ bool FindDiffRange(void *a, void *b, size_t bufSize, size_t &diffStart, size_t & return diffStart < bufSize; } +uint32_t CalcNumMips(int w, int h, int d) +{ + int mipLevels = 1; + + while(w > 1 || h > 1 || d > 1) + { + w = RDCMAX(1, w>>1); + h = RDCMAX(1, h>>1); + d = RDCMAX(1, d>>1); + mipLevels++; + } + + return mipLevels; +} + static string &logfile() { static string fn; diff --git a/renderdoc/common/common.h b/renderdoc/common/common.h index 4f8f29d67..a2a1ab782 100644 --- a/renderdoc/common/common.h +++ b/renderdoc/common/common.h @@ -26,6 +26,7 @@ #pragma once #include +#include #include "globalconfig.h" @@ -84,6 +85,7 @@ inline T AlignUp16(T x) { return (x+0xf) & (~0xf); } #define MAKE_FOURCC(a, b, c, d) (((uint32_t)(d) << 24) | ((uint32_t)(c) << 16) | ((uint32_t)(b) << 8) | (uint32_t)(a)) bool FindDiffRange(void *a, void *b, size_t bufSize, size_t &diffStart, size_t &diffEnd); +uint32_t CalcNumMips(int Width, int Height, int Depth); ///////////////////////////////////////////////// // Debugging features diff --git a/renderdoc/driver/d3d11/d3d11_resources.cpp b/renderdoc/driver/d3d11/d3d11_resources.cpp index 7fb7206cd..32de060df 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.cpp +++ b/renderdoc/driver/d3d11/d3d11_resources.cpp @@ -64,21 +64,6 @@ map WrappedTexture WrappedID3D11Buffer::m_BufferList; map WrappedShader::m_ShaderList; -UINT CalcNumMips(int w, int h, int d) -{ - int mipLevels = 1; - - while(w > 1 || h > 1 || d > 1) - { - w = RDCMAX(1, w>>1); - h = RDCMAX(1, h>>1); - d = RDCMAX(1, d>>1); - mipLevels++; - } - - return mipLevels; -} - UINT GetMipForSubresource(ID3D11Resource *res, int Subresource) { D3D11_RESOURCE_DIMENSION dim; diff --git a/renderdoc/driver/d3d11/d3d11_resources.h b/renderdoc/driver/d3d11/d3d11_resources.h index 94ff49d4b..5f51f6392 100644 --- a/renderdoc/driver/d3d11/d3d11_resources.h +++ b/renderdoc/driver/d3d11/d3d11_resources.h @@ -67,8 +67,6 @@ UINT GetByteSize(ID3D11Texture1D *tex, int SubResource); UINT GetByteSize(ID3D11Texture2D *tex, int SubResource); UINT GetByteSize(ID3D11Texture3D *tex, int SubResource); -UINT CalcNumMips(int Width, int Height, int Depth); - UINT GetMipForSubresource(ID3D11Resource *res, int Subresource); // returns block size for block-compressed formats