moved some stuff around to avoid code duplication and finish up gl 2D texture code

This commit is contained in:
jp9000
2013-10-05 00:34:43 -07:00
parent 9f0b7f25f6
commit 5c92f22f0d
6 changed files with 94 additions and 38 deletions

View File

@@ -58,30 +58,6 @@ static inline uint32_t GetWinVer()
return (ovi.dwMajorVersion << 8) | (ovi.dwMinorVersion);
}
static inline uint32_t GetFormatBPP(gs_color_format format)
{
switch (format) {
case GS_A8: return 1;
case GS_R8: return 1;
case GS_RGBA: return 4;
case GS_BGRX: return 4;
case GS_BGRA: return 4;
case GS_R10G10B10A2: return 4;
case GS_RGBA16: return 8;
case GS_R16: return 2;
case GS_RGBA16F: return 8;
case GS_RGBA32F: return 16;
case GS_RG16F: return 4;
case GS_RG32F: return 8;
case GS_R16F: return 2;
case GS_R32F: return 4;
case GS_DXT1: return 0;
case GS_DXT3: return 0;
case GS_DXT5: return 0;
default: return 0;
}
}
static inline DXGI_FORMAT ConvertGSTextureFormat(gs_color_format format)
{
switch (format) {

View File

@@ -37,16 +37,18 @@ static inline uint32_t numActualLevels(uint32_t levels, uint32_t width,
void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd, void **data)
{
uint32_t rowSizeBytes = width * GetFormatBPP(format);
uint32_t texSizeBytes = height * rowSizeBytes;
uint32_t rowSizeBytes = width * get_format_bpp(format);
uint32_t texSizeBytes = height * rowSizeBytes / 8;
size_t textures = type == GS_TEXTURE_2D ? 1 : 6;
uint32_t actual_levels = numActualLevels(levels, width, height);
rowSizeBytes /= 8;
for (size_t i = 0; i < textures; i++) {
uint32_t newRowSize = rowSizeBytes;
uint32_t newTexSize = texSizeBytes;
for (size_t j = 0; j < actual_levels; j++) {
for (uint32_t j = 0; j < actual_levels; j++) {
D3D11_SUBRESOURCE_DATA newSRD;
newSRD.pSysMem = *data;
newSRD.SysMemPitch = newRowSize;