Add GrD3DUtil.
Trying to stage the texture format CLs in a little at a time. Bug: skia:9935 Change-Id: I0fc6fe09fdb55d6c24b53af7edbcc8e8fc857ed7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/273803 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Jim Van Verth <jvanverth@google.com>
This commit is contained in:
parent
c86c83cd80
commit
62a644bf5a
@ -737,6 +737,8 @@ skia_direct3d_sources = [
|
||||
"$_src/gpu/d3d/GrD3DGpu.h",
|
||||
"$_src/gpu/d3d/GrD3DOpsRenderPass.cpp",
|
||||
"$_src/gpu/d3d/GrD3DOpsRenderPass.h",
|
||||
"$_src/gpu/d3d/GrD3DUtil.cpp",
|
||||
"$_src/gpu/d3d/GrD3DUtil.h",
|
||||
]
|
||||
|
||||
skia_dawn_sources = [
|
||||
|
31
src/gpu/d3d/GrD3DUtil.cpp
Normal file
31
src/gpu/d3d/GrD3DUtil.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "src/gpu/d3d/GrD3DUtil.h"
|
||||
|
||||
#include "src/gpu/GrContextPriv.h"
|
||||
#include "src/gpu/GrDataUtils.h"
|
||||
#include "src/gpu/d3d/GrD3DGpu.h"
|
||||
#include "src/sksl/SkSLCompiler.h"
|
||||
|
||||
bool GrDxgiFormatIsCompressed(DXGI_FORMAT format) {
|
||||
switch (format) {
|
||||
case DXGI_FORMAT_BC1_UNORM:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
||||
|
||||
SkImage::CompressionType GrDxgiFormatToCompressionType(DXGI_FORMAT format) {
|
||||
switch (format) {
|
||||
case DXGI_FORMAT_BC1_UNORM: return SkImage::CompressionType::kBC1_RGBA8_UNORM;
|
||||
default: return SkImage::CompressionType::kNone;
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
}
|
51
src/gpu/d3d/GrD3DUtil.h
Normal file
51
src/gpu/d3d/GrD3DUtil.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrD3DUtil_DEFINED
|
||||
#define GrD3DUtil_DEFINED
|
||||
|
||||
#include "include/core/SkImage.h"
|
||||
#include "include/gpu/GrTypes.h"
|
||||
#include "include/gpu/d3d/GrD3D12.h"
|
||||
#include "include/private/GrTypesPriv.h"
|
||||
|
||||
/**
|
||||
* Returns true if the format is compressed.
|
||||
*/
|
||||
bool GrDxgiFormatIsCompressed(DXGI_FORMAT);
|
||||
|
||||
/**
|
||||
* Maps a dxgi format into the CompressionType enum if applicable.
|
||||
*/
|
||||
SkImage::CompressionType GrDxgiFormatToCompressionType(DXGI_FORMAT dxgiFormat);
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
static constexpr const char* GrDxgiFormatToStr(DXGI_FORMAT dxgiFormat) {
|
||||
switch (dxgiFormat) {
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM: return "R8G8B8A8_UNORM";
|
||||
case DXGI_FORMAT_R8_UNORM: return "R8_UNORM";
|
||||
case DXGI_FORMAT_B8G8R8A8_UNORM: return "B8G8R8A8_UNORM";
|
||||
case DXGI_FORMAT_B5G6R5_UNORM: return "R5G6B5_UNORM";
|
||||
case DXGI_FORMAT_R16G16B16A16_FLOAT: return "R16G16B16A16_FLOAT";
|
||||
case DXGI_FORMAT_R16_FLOAT: return "R16_FLOAT";
|
||||
case DXGI_FORMAT_R8G8_UNORM: return "R8G8_UNORM";
|
||||
case DXGI_FORMAT_R10G10B10A2_UNORM: return "R10G10B10A2_UNORM";
|
||||
case DXGI_FORMAT_B4G4R4A4_UNORM: return "B4G4R4A4_UNORM";
|
||||
case DXGI_FORMAT_R32G32B32A32_FLOAT: return "R32G32B32A32_FLOAT";
|
||||
case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: return "R8G8B8A8_UNORM_SRGB";
|
||||
case DXGI_FORMAT_BC1_UNORM: return "BC1_UNORM";
|
||||
case DXGI_FORMAT_R16_UNORM: return "R16_UNORM";
|
||||
case DXGI_FORMAT_R16G16_UNORM: return "R16G16_UNORM";
|
||||
case DXGI_FORMAT_R16G16B16A16_UNORM: return "R16G16B16A16_UNORM";
|
||||
case DXGI_FORMAT_R16G16_FLOAT: return "R16G16_FLOAT";
|
||||
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user