//-------------------------------------------------------------------------------------------------------------- //创建二维纹理 Texture* D3D9TextureManager::CreateTexture( UINT nWidth, UINT nHeight, PixelFormat ePixelFormat, TextureUsage Type, int nNumLevels ) { //如果为压缩纹理格式 if( ePixelFormat & PF_COMPRESS_MASK ) { //检测指定纹理压缩格式是否可用 if( !CheckCompressFormat( ePixelFormat ) ) Except( Exception::ERR_INTERNAL_ERROR, "硬件不支持指定的纹理压缩格式,无法创建纹理。" ); if( !IsPow2( nWidth ) || !IsPow2( nHeight ) ) Except( Exception::ERR_INTERNAL_ERROR, "无法创建非 2 次幂尺寸的压缩纹理。" ); } //获取最佳的纹理尺寸 UINT texWidth = 0; UINT texHeight = 0; GetBestSize( nWidth, nHeight, texWidth, texHeight ); nNumLevels = (UINT)( ( nNumLevels == -1 ) ? mDefTexLevels : nNumLevels ); Texture* pTex = new D3D9Texture( texWidth, texHeight, ePixelFormat, nNumLevels, Type ); *mTextureList.Push() = pTex; ++mNumTextures; return pTex; }
void BlockArrangement::ArrangeLinearReduction(dim3* grid, dim3* block, int* num_of_blocks, int* np2_last_block, int* elements_last_block, int* threads_last_block, int num_of_elements) { if (!block || !grid || !num_of_blocks || !np2_last_block) return; int max_threads = dev_prop_->maxThreadsPerBlock; float blocks = std::ceil(static_cast<float>(num_of_elements) / (max_threads * 2.0f)); int num_of_blocks_temp = std::max(1, static_cast<int>(blocks)); int num_of_threads = max_threads; if (num_of_blocks_temp == 1) num_of_threads = IsPow2(num_of_elements) ? num_of_elements / 2 : (1 << std::ilogb(num_of_elements)); int elements_per_block = num_of_threads * 2; int elements_last_block_temp = num_of_elements - (num_of_blocks_temp - 1) * elements_per_block; int threads_last_block_temp = std::max(1, elements_last_block_temp / 2); *np2_last_block = 0; if (elements_last_block_temp != elements_per_block) { *np2_last_block = 1; if (!IsPow2(elements_last_block_temp)) threads_last_block_temp = 1 << std::ilogb(elements_last_block_temp); } *num_of_blocks = num_of_blocks_temp; *block = dim3(num_of_threads, 1, 1); *grid = dim3(std::max(1, num_of_blocks_temp - *np2_last_block), 1, 1); if (elements_last_block) *elements_last_block = elements_last_block_temp; if (threads_last_block) *threads_last_block = threads_last_block_temp; }
Texture::Texture(const Bitmap &bitmap, bool mip) : mTextureId(0), mSize(bitmap.GetSize()), mMip(mip) { if(!mSize.x || !mSize.y || !IsPow2(mSize.x) || !IsPow2(mSize.y)) { throw "Texture not created. Incorrect size."; } bool smoothing = false; GL_CALL(glGenTextures(1, &mTextureId)); if(!mTextureId) { throw "Texture not created. GL error."; } GL_CALL(glBindTexture(GL_TEXTURE_2D, mTextureId)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smoothing ? GL_LINEAR : GL_NEAREST)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smoothing ? GL_LINEAR : GL_NEAREST)); if (mip) { GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smoothing ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smoothing ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST)); } else { GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, smoothing ? GL_LINEAR : GL_NEAREST)); GL_CALL(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, smoothing ? GL_LINEAR : GL_NEAREST)); } GL_CALL(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, mSize.x, mSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, &bitmap.GetRaw()[0])); }
static int NextPow2(int i) { if(IsPow2(i)) { return i; } else { int ret = 2; while(i != 1) { ret *= 2; i /= 2; } return ret; } }
static PyObject * InvWaveletTransform(PyObject *self, PyObject *args, PyObject *keywds) { //define array object PyArrayObject * input, * output; int filter = 0, dorder = 4; static char *kwlist[] = {"input","filter","dorder", NULL}; //read in object if (!PyArg_ParseTupleAndKeywords(args, keywds, "O|ii", kwlist, &input, &filter, &dorder)) return NULL; //copy input to output - first create the array output = (PyArrayObject*) PyArray_SimpleNew(input->nd, input->dimensions, PyArray_DOUBLE); if(output == NULL) return NULL; //calculate no of data points in array int n,size=1; for(n=0;n<output->nd;n++) size *= output->dimensions[n]; //copy input data to output data for(n=0;n<size;n++) *(((double*)output->data) + n) = *(((double*)input->data) + n); //check that data is a power of 2! if(!IsPow2(size)){ fprintf(stderr, "DoIFWT Error: data for DoIFWT is not a power of 2. Exiting...\n"); return PyFloat_FromDouble(1.); } //do inv wavelet transform **in place** DoIFWT((double*)output->data,size,dorder); //return the transformed array return PyArray_Return(output); }
/* ** Do a Fast Fourier Transform based multiplication. */ INT32 FFTMul(BigInt Prod, BigInt Num1, BigInt Num2, size_t NumLen, size_t ProdLen, INT32 Scale) /* ** Scale=0 means don't multiply by Scale. ** Scale!=0 means do multiply by Scale. (Usually 10.) ** ** If a scaling causes a carry, that carry will be returned, else ** zero will be returned. */ { size_t x; size_t NumLen2 = NumLen * 2; size_t FFTLen2=CalcFFTLen(NumLen); FFT_DATA_TYPE *FFTNum2=FFTNum; int All16=0;INT32 ScaleCarry=0; if (NumLen <= 64) {INT32 *Buf1=(INT32*)CoreMemPtr; INT32 *Buf2=Buf1+NumLen; INT32 *DBuf=Buf2+NumLen; ReadNumIntoBuf(Num1,Buf1,NumLen); ReadNumIntoBuf(Num2,Buf2,NumLen); BlockClear(DBuf,DBuf+NumLen*2); BlockSlowMul(DBuf,Buf1,Buf2,NumLen); if (Scale) ScaleCarry=BlockMulBy(DBuf,DBuf,Scale,0,NumLen*2); WriteBufIntoNum(DBuf,Prod,ProdLen); return ScaleCarry; } if (FFTLen2 < 16) {UINT32 *Buf1=(UINT32*)CoreMemPtr; UINT32 *Buf2=Buf1+NumLen; UINT32 *DBuf=Buf2+NumLen; double *FFTNum1=(double*)(DBuf+NumLen*2); int FFTLen=NumLen*2*2; double *FFTNum2=FFTNum1+FFTLen; ReadNumIntoBuf(Num1,Buf1,NumLen); ReadNumIntoBuf(Num2,Buf2,NumLen); BlockClear(DBuf,DBuf+NumLen*2); SimpleFFTMul(DBuf,Num1,Num2,NumLen,FFTLen,FFTNum1,FFTNum2); if (Scale) ScaleCarry=BlockMulBy(DBuf,DBuf,Scale,0,NumLen*2); WriteBufIntoNum(DBuf,Prod,ProdLen); return ScaleCarry; } if (NumLen > FFTLimit) { if (Cfg.AllowFractalMul) { FractalMul(FMWork,Num1,Num2,NumLen); if (Scale) ScaleCarry=MulBy(Prod,FMWork,Scale,ProdLen); else Copy(Prod,FMWork,ProdLen); return ScaleCarry; } else FatalError("Somehow BigMul was called with a length (%lu) longer than FFTLimit (%lu)\n", (ULINT)NumLen,(ULINT)FFTLimit); } MaxFFTError=0.0; if (FFTLen2*2*sizeof(FFT_DATA_TYPE) <= CoreMemAvail) {All16=-2;FFTNum2=FFTNum+FFTLen2;} if (!IsPow2(NumLen)) FatalError("The FFT size is not a power of two\n"); if (NumLen > MaxFFTLen/RawIntDigits) FatalError("Somehow FFTMul was called with a number longer than MAX_FFT_LIMIT.\n%lu %lu\n", (UINT32)NumLen,(UINT32)MaxFFTLen); if (NumLen > FFTLimit) FatalError("Somehow BigMul was called with a length (%lu) longer than FFTLimit (%lu)\n", (ULINT)NumLen,(ULINT)FFTLimit); DumpDebug("FFT %s ",Num2Str(NumLen*RawIntDigits)); StartTimer(FFTMulTime); FFTDisk-=DiskIOTime; if (Num1 == Num2) {int Line=0; if (Num1IsCached || Num2IsCached) Line=CheckFFTCache(Num2,NumLen,Num1IsCached + Num2IsCached,0); if (Line) LoadFFTFromCache(Line,FFTNum); else { DumpDebug("F"); FwdTransform(FFTNum,Num2,NumLen); if (SaveNum2FFT || SaveNum1FFT) SaveFFTIntoCache(FFTNum, FFTLen2, Num2, NumLen, SaveNum1FFT + SaveNum2FFT,0); } DoConvolution(FFTNum,-1,FFTLen2); } else {int Line1=0,Line2=0; if (Num1IsCached) Line1=CheckFFTCache(Num1,NumLen,Num1IsCached,0); if (Num2IsCached) Line2=CheckFFTCache(Num2,NumLen,Num2IsCached,0); if (Line1 && Line2) { DumpDebug("Caches..."); LoadFFTFromCache(Line1,FFTNum); DoConvolution(FFTNum,Line2,FFTLen2); } else if (Line1) { DumpDebug("Cache...F"); FwdTransform(FFTNum,Num2,NumLen); if (SaveNum2FFT) SaveFFTIntoCache(FFTNum,FFTLen2,Num2,NumLen, SaveNum2FFT,0); DoConvolution(FFTNum,Line1,FFTLen2); } else if (Line2) { DumpDebug("Cache...F"); FwdTransform(FFTNum,Num1,NumLen); if (SaveNum1FFT) SaveFFTIntoCache(FFTNum,FFTLen2,Num1,NumLen, SaveNum1FFT,0); DoConvolution(FFTNum,Line2,FFTLen2); } else { if (SaveNum1FFT) { DumpDebug("F"); FwdTransform(FFTNum,Num1,NumLen); Line1=SaveFFTIntoCache(FFTNum,FFTLen2,Num1,NumLen, SaveNum1FFT,0); if (All16) Line1=-2; else if (Line1==0) SaveFFTIntoCache0(FFTNum,FFTLen2); DumpDebug("F"); FwdTransform(FFTNum2,Num2,NumLen); if (SaveNum2FFT) SaveFFTIntoCache(FFTNum2,FFTLen2,Num2,NumLen, SaveNum2FFT,0); DoConvolution(FFTNum,Line1,FFTLen2); } else if (SaveNum2FFT) { DumpDebug("F"); FwdTransform(FFTNum,Num2,NumLen); Line2=SaveFFTIntoCache(FFTNum,FFTLen2,Num2,NumLen, SaveNum2FFT,0); if (All16) Line2=-2; else if (Line2==0) SaveFFTIntoCache0(FFTNum,FFTLen2); DumpDebug("F"); FwdTransform(FFTNum2,Num1,NumLen); if (SaveNum1FFT) SaveFFTIntoCache(FFTNum2,FFTLen2,Num1,NumLen, SaveNum1FFT,0); DoConvolution(FFTNum,Line2,FFTLen2); } else { Line2=All16; DumpDebug("F"); FwdTransform(FFTNum,Num1,NumLen); if (!All16) SaveFFTIntoCache0(FFTNum,FFTLen2); DumpDebug("F"); FwdTransform(FFTNum2,Num2,NumLen); DoConvolution(FFTNum,Line2,FFTLen2); } } } DeleteFFTCache(0); /* get rid of the convolution file */ /* ** Now do an Inverse FFT */ DumpDebug("R"); RevTransform(FFTNum,NumLen); DumpDebug("Carries..."); StartTimer(CarryTime); MaxFFTError=0.0; {FFT_DATA_TYPE Carry, Round; INT32 *ProdBuf=(INT32*)FixedBuf; size_t ProdNdx,ProdPos,ProdBufLen=FIXEDBUF_SIZE/sizeof(INT32); double PyramidError; int SF=4+(RAW_FFT_DIG*2); int q; ProdNdx=ProdBufLen;ProdPos=NumLen2; F_Clear(&Carry); F_Clear(&Round);Round.Data[SF+1]=50000000; for (x=0; x<FFTLen2;x++) { if (FFTNum[x].Data[0] != 0) fprintf(stderr,"Warning, FFT appears to be overflow. %ld %d\n",x,FFTNum[x].Data[0]); PyramidError=FFTNum[x].Data[SF+1]/1.0e8; PyramidError-=0.5;PyramidError=fabs(PyramidError);PyramidError=0.5-PyramidError; if (PyramidError > MaxFFTError) MaxFFTError = PyramidError; F_Add(&FFTNum[x],&Round,&FFTNum[x]); F_Add(&Carry,&FFTNum[x],&Carry); ProdNdx-=RAW_FFT_DIG;ProdPos-=RAW_FFT_DIG; for (q=RAW_FFT_DIG-1;q>=0;q--) { ProdBuf[ProdNdx+q]=Carry.Data[SF]; F_ShiftR(&Carry); } {int z;for (z=SF+1;z<FIXPOINT_LEN;z++) Carry.Data[z]=0;} if (ProdNdx==0) {size_t z; if (ProdPos >= ProdLen) z=0; else if (ProdPos+ProdBufLen < ProdLen) z=ProdBufLen; else z=ProdLen-ProdPos; if ((Scale) && (z)) ScaleCarry=BlockMulBy(ProdBuf,ProdBuf,Scale,ScaleCarry,z); if (z) WriteBufIntoNum(ProdBuf,Prod+ProdPos,z); ProdNdx=ProdBufLen; } } if (ProdNdx!=ProdBufLen) {size_t z; ProdBufLen=ProdBufLen-ProdNdx; if (ProdPos >= ProdLen) z=0; else if (ProdPos+ProdBufLen < ProdLen) z=ProdBufLen; else z=ProdLen-ProdPos; if ((Scale) && (z)) ScaleCarry=BlockMulBy(ProdBuf+ProdNdx,ProdBuf+ProdNdx,Scale,ScaleCarry,z); if (z) WriteBufIntoNum(ProdBuf+ProdNdx,Prod+ProdPos,z); } StopTimer(CarryTime); /* F_Clear(&Carry); // F_Clear(&Round);Round.Data[9]=50000000; // F_Clear(&Round);Round.Data[7]=50000000; F_Clear(&Round);Round.Data[11]=50000000; for (x=0; x<FFTLen2;x++) { if (FFTNum[x].Data[0] != 0) fprintf(stderr,"Warning, FFT appears to be overflow. %ld %d\n",x,FFTNum[x].Data[0]); // PyramidError=FFTNum[x].Data[9]/1.0e8; // PyramidError=FFTNum[x].Data[7]/1.0e8; PyramidError=FFTNum[x].Data[11]/1.0e8; PyramidError-=0.5; PyramidError=fabs(PyramidError); PyramidError=0.5-PyramidError; if (PyramidError > MaxFFTError) MaxFFTError = PyramidError; F_Add(&FFTNum[x],&Round,&FFTNum[x]); F_Add(&Carry,&FFTNum[x],&Carry); // P[x]=Carry.Data[8]; // P[x]=Carry.Data[6]; P[x]=Carry.Data[10]; F_ShiftR(&Carry); // {int z;for (z=9;z<FIXPOINT_LEN;z++) Carry.Data[z]=0;} // {int z;for (z=7;z<FIXPOINT_LEN;z++) Carry.Data[z]=0;} {int z;for (z=11;z<FIXPOINT_LEN;z++) Carry.Data[z]=0;} } StopTimer(CarryTime); for (x=0;x<FFTLen2/2;x++) {UINT32 t=P[x];P[x]=P[FFTLen2-x-1];P[FFTLen2-x-1]=t;} if (Scale) ScaleCarry=BlockMulBy((INT32*)P,(INT32*)P,Scale,0,Min(ProdLen,NumLen2)); WriteBufIntoNum((INT32*)P,Prod,Min(ProdLen,NumLen2)); */ } /* ** Do a bit of 'sanity' error checking. This value ** is based on some testing with a 'test jig' and ** personal opinion. Should be good enough to catch ** systems with poor FPUs. However, if the value ever ** actually reaches 0.5, then you know for a FACT that ** the FFTMul() has failed. */ if (MaxFFTError >= 0.2) { printf("\n**WARNING** Len=%lu Max FFT Error: %f\n", (ULINT)NumLen,(double)MaxFFTError); puts("Either the FFT is approaching its limit, or a sofware"); puts("or hardware error occured. This can also be caused by"); puts("a program bug, poor trig, etc. You may wish to lower"); puts("the MaxFFTLen limit in fft.h and run it again."); ExitPrg(EXIT_FAILURE); } StopTimer(FFTMulTime); FFTDisk+=DiskIOTime; DumpDebug("Done FFT.\n"); return ScaleCarry; }
inline T AlignUp( T val, size_t alignment ) { MM_ASSERT( IsPow2( alignment ) ); return (T)( ( (UINT_PTR)val + (alignment-1) ) & ~( alignment-1 )); }
Texture* D3D10Texture::CreateFromFile(CTSTR lpFile, BOOL bBuildMipMaps) { HRESULT err; D3DX10_IMAGE_INFO ii; if(FAILED(D3DX10GetImageInfoFromFile(lpFile, NULL, &ii, NULL))) { AppWarning(TEXT("D3D10Texture::CreateFromFile: Could not get information about texture file '%s'"), lpFile); return NULL; } //------------------------------------------ if(bBuildMipMaps && (!IsPow2(ii.Width) || !IsPow2(ii.Height))) bBuildMipMaps = FALSE; D3DX10_IMAGE_LOAD_INFO ili; ili.Width = D3DX10_DEFAULT; ili.Height = D3DX10_DEFAULT; ili.Depth = D3DX10_DEFAULT; ili.FirstMipLevel = D3DX10_DEFAULT; ili.MipLevels = bBuildMipMaps ? 0 : 1; ili.Usage = (D3D10_USAGE)D3DX10_DEFAULT; ili.BindFlags = D3DX10_DEFAULT; ili.CpuAccessFlags = D3DX10_DEFAULT; ili.MiscFlags = D3DX10_DEFAULT; ili.Format = (DXGI_FORMAT)D3DX10_DEFAULT; ili.Filter = D3DX10_DEFAULT; ili.MipFilter = D3DX10_DEFAULT; ili.pSrcInfo = NULL; ID3D10Resource *texResource; if(FAILED(err = D3DX10CreateTextureFromFile(GetD3D(), lpFile, &ili, NULL, &texResource, NULL))) { AppWarning(TEXT("D3D10Texture::CreateFromFile: failed to load '%s'"), lpFile); return NULL; } //------------------------------------------ D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc; zero(&resourceDesc, sizeof(resourceDesc)); resourceDesc.Format = ii.Format; resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; resourceDesc.Texture2D.MipLevels = bBuildMipMaps ? -1 : 1; ID3D10ShaderResourceView *resource; if(FAILED(err = GetD3D()->CreateShaderResourceView(texResource, &resourceDesc, &resource))) { SafeRelease(texResource); AppWarning(TEXT("D3D10Texture::CreateFromFile: CreateShaderResourceView failed, result = 0x%08lX"), err); return NULL; } //------------------------------------------ ID3D10Texture2D *tex2D; err = texResource->QueryInterface(__uuidof(ID3D10Texture2D), (void**)&tex2D); if(FAILED(err)) { SafeRelease(texResource); SafeRelease(resource); AppWarning(TEXT("D3D10Texture::CreateFromFile: could not query texture interface")); return NULL; } texResource->Release(); //------------------------------------------ D3D10Texture *newTex = new D3D10Texture; newTex->resource = resource; newTex->texture = tex2D; newTex->width = ii.Width; newTex->height = ii.Height; switch(ii.Format) { case DXGI_FORMAT_R8_UNORM: newTex->format = GS_ALPHA; break; case DXGI_FORMAT_A8_UNORM: newTex->format = GS_GRAYSCALE; break; case DXGI_FORMAT_B8G8R8X8_UNORM: newTex->format = GS_BGR; break; case DXGI_FORMAT_B8G8R8A8_UNORM: newTex->format = GS_BGRA; break; case DXGI_FORMAT_R8G8B8A8_UNORM: newTex->format = GS_RGBA; break; case DXGI_FORMAT_R16G16B16A16_FLOAT: newTex->format = GS_RGBA16F; break; case DXGI_FORMAT_R32G32B32A32_FLOAT: newTex->format = GS_RGBA32F; break; case DXGI_FORMAT_BC1_UNORM: newTex->format = GS_DXT1; break; case DXGI_FORMAT_BC2_UNORM: newTex->format = GS_DXT3; break; case DXGI_FORMAT_BC3_UNORM: newTex->format = GS_DXT5; break; default: newTex->format = GS_UNKNOWNFORMAT; } return newTex; }
Texture* D3D10Texture::CreateTexture(unsigned int width, unsigned int height, GSColorFormat colorFormat, void *lpData, BOOL bGenMipMaps, BOOL bStatic) { HRESULT err; if(colorFormat >= GS_DXT1) { AppWarning(TEXT("D3D10Texture::CreateTexture: tried to create a blank DXT texture. Use CreateFromFile instead.")); return NULL; } DXGI_FORMAT format = convertFormat[(UINT)colorFormat]; if(bGenMipMaps && (!IsPow2(width) || !IsPow2(height))) { AppWarning(TEXT("D3D10Texture::CreateTexture: Cannot generate mipmaps for a non-power-of-two sized texture. Disabling mipmap generation.")); bGenMipMaps = FALSE; } D3D10_TEXTURE2D_DESC td; zero(&td, sizeof(td)); td.Width = width; td.Height = height; td.MipLevels = bGenMipMaps ? 0 : 1; td.ArraySize = 1; td.Format = format; td.BindFlags = D3D10_BIND_SHADER_RESOURCE; td.SampleDesc.Count = 1; td.Usage = bStatic ? D3D10_USAGE_DEFAULT : D3D10_USAGE_DYNAMIC; td.CPUAccessFlags = bStatic ? 0 : D3D10_CPU_ACCESS_WRITE; D3D10_SUBRESOURCE_DATA srd; D3D10_SUBRESOURCE_DATA *lpSRD; if(lpData) { srd.pSysMem = lpData; srd.SysMemPitch = width*formatPitch[(UINT)colorFormat]; srd.SysMemSlicePitch = 0; lpSRD = &srd; } else lpSRD = NULL; ID3D10Texture2D *texVal; if(FAILED(err = GetD3D()->CreateTexture2D(&td, lpSRD, &texVal))) { AppWarning(TEXT("D3D10Texture::CreateTexture: CreateTexture2D failed, result = 0x%08lX"), err); return NULL; } //------------------------------------------ D3D10_SHADER_RESOURCE_VIEW_DESC resourceDesc; zero(&resourceDesc, sizeof(resourceDesc)); resourceDesc.Format = format; resourceDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D; resourceDesc.Texture2D.MipLevels = bGenMipMaps ? -1 : 1; ID3D10ShaderResourceView *resource; if(FAILED(err = GetD3D()->CreateShaderResourceView(texVal, &resourceDesc, &resource))) { SafeRelease(texVal); AppWarning(TEXT("D3D10Texture::CreateTexture: CreateShaderResourceView failed, result = 0x%08lX"), err); return NULL; } //------------------------------------------ D3D10Texture *newTex = new D3D10Texture; newTex->format = colorFormat; newTex->resource = resource; newTex->texture = texVal; newTex->bDynamic = !bStatic; newTex->width = width; newTex->height = height; return newTex; }
s64 RoundIntUpToMultipleOfPow2(s64 x, s64 n) { assert(IsPow2(n)); return (x + n-1) & ~(n-1); }
int RoundIntUpToMultipleOfPow2(int x, int n) { assert(IsPow2(n)); return (x + n-1) & ~(n-1); }