|
| 1 | +/* |
| 2 | + * Copyright 2020 Google Inc. |
| 3 | + * |
| 4 | + * Use of this source code is governed by a BSD-style license that can be |
| 5 | + * found in the LICENSE file. |
| 6 | + */ |
| 7 | + |
| 8 | +#include "include/gpu/GrBackendSurface.h" |
| 9 | +#include "include/gpu/d3d/GrD3DBackendContext.h" |
| 10 | + |
| 11 | +#include "src/gpu/GrProgramDesc.h" |
| 12 | +#include "src/gpu/GrShaderCaps.h" |
| 13 | +#include "src/gpu/d3d/GrD3DCaps.h" |
| 14 | +#include "src/gpu/d3d/GrD3DGpu.h" |
| 15 | + |
| 16 | +GrD3DCaps::GrD3DCaps(const GrContextOptions& contextOptions, GrProtected isProtected) |
| 17 | + : INHERITED(contextOptions) { |
| 18 | + /************************************************************************** |
| 19 | + * GrCaps fields |
| 20 | + **************************************************************************/ |
| 21 | + fMipMapSupport = true; // always available in Direct3D |
| 22 | + fNPOTTextureTileSupport = false; // TODO: figure this out |
| 23 | + fReuseScratchTextures = true; //TODO: figure this out |
| 24 | + fGpuTracingSupport = false; //TODO: figure this out |
| 25 | + fOversizedStencilSupport = false; //TODO: figure this out |
| 26 | + fInstanceAttribSupport = true; |
| 27 | + |
| 28 | + // TODO: implement these |
| 29 | + fSemaphoreSupport = false; |
| 30 | + fFenceSyncSupport = false; |
| 31 | + fCrossContextTextureSupport = false; |
| 32 | + fHalfFloatVertexAttributeSupport = false; |
| 33 | + |
| 34 | + // We always copy in/out of a transfer buffer so it's trivial to support row bytes. |
| 35 | + fReadPixelsRowBytesSupport = true; |
| 36 | + fWritePixelsRowBytesSupport = true; |
| 37 | + |
| 38 | + // TODO: figure this out |
| 39 | + fTransferFromBufferToTextureSupport = false; |
| 40 | + fTransferFromSurfaceToBufferSupport = false; |
| 41 | + |
| 42 | + // TODO: figure this out |
| 43 | + fMaxRenderTargetSize = 4096; |
| 44 | + fMaxTextureSize = 4096; |
| 45 | + |
| 46 | + fDynamicStateArrayGeometryProcessorTextureSupport = false; // TODO: figure this out |
| 47 | + |
| 48 | + fShaderCaps.reset(new GrShaderCaps(contextOptions)); |
| 49 | + |
| 50 | + this->init(contextOptions); |
| 51 | +} |
| 52 | + |
| 53 | +bool GrD3DCaps::onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src, |
| 54 | + const SkIRect& srcRect, const SkIPoint& dstPoint) const { |
| 55 | + return false; |
| 56 | +} |
| 57 | + |
| 58 | +void GrD3DCaps::init(const GrContextOptions& contextOptions) { |
| 59 | + // TODO |
| 60 | + |
| 61 | + this->finishInitialization(contextOptions); |
| 62 | +} |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +bool GrD3DCaps::isFormatSRGB(const GrBackendFormat& format) const { |
| 67 | + // TODO |
| 68 | + return false; |
| 69 | +} |
| 70 | + |
| 71 | +SkImage::CompressionType GrD3DCaps::compressionType(const GrBackendFormat& format) const { |
| 72 | + // TODO |
| 73 | + return SkImage::CompressionType::kNone; |
| 74 | +} |
| 75 | + |
| 76 | +bool GrD3DCaps::isFormatTexturableAndUploadable(GrColorType ct, |
| 77 | + const GrBackendFormat& format) const { |
| 78 | + // TODO |
| 79 | + return false; |
| 80 | +} |
| 81 | + |
| 82 | +bool GrD3DCaps::isFormatTexturable(const GrBackendFormat& format) const { |
| 83 | + // TODO |
| 84 | + return false; |
| 85 | +} |
| 86 | + |
| 87 | +bool GrD3DCaps::isFormatAsColorTypeRenderable(GrColorType ct, const GrBackendFormat& format, |
| 88 | + int sampleCount) const { |
| 89 | + if (!this->isFormatRenderable(format, sampleCount)) { |
| 90 | + return false; |
| 91 | + } |
| 92 | + // TODO |
| 93 | + return false; |
| 94 | +} |
| 95 | + |
| 96 | +bool GrD3DCaps::isFormatRenderable(const GrBackendFormat& format, int sampleCount) const { |
| 97 | + // TODO |
| 98 | + return false; |
| 99 | +} |
| 100 | + |
| 101 | +int GrD3DCaps::getRenderTargetSampleCount(int requestedCount, |
| 102 | + const GrBackendFormat& format) const { |
| 103 | + // TODO |
| 104 | + return 0; |
| 105 | +} |
| 106 | + |
| 107 | +int GrD3DCaps::maxRenderTargetSampleCount(const GrBackendFormat& format) const { |
| 108 | + // TODO |
| 109 | + return 0; |
| 110 | +} |
| 111 | + |
| 112 | +size_t GrD3DCaps::bytesPerPixel(const GrBackendFormat& format) const { |
| 113 | + // TODO |
| 114 | + return 0; |
| 115 | +} |
| 116 | + |
| 117 | +GrCaps::SupportedWrite GrD3DCaps::supportedWritePixelsColorType(GrColorType surfaceColorType, |
| 118 | + const GrBackendFormat& surfaceFormat, |
| 119 | + GrColorType srcColorType) const { |
| 120 | + // TODO |
| 121 | + return {GrColorType::kUnknown, 0}; |
| 122 | +} |
| 123 | + |
| 124 | +GrCaps::SurfaceReadPixelsSupport GrD3DCaps::surfaceSupportsReadPixels( |
| 125 | + const GrSurface* surface) const { |
| 126 | + if (surface->isProtected()) { |
| 127 | + return SurfaceReadPixelsSupport::kUnsupported; |
| 128 | + } |
| 129 | + // TODO |
| 130 | + return SurfaceReadPixelsSupport::kUnsupported; |
| 131 | +} |
| 132 | + |
| 133 | +bool GrD3DCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const { |
| 134 | + // TODO |
| 135 | + return false; |
| 136 | +} |
| 137 | + |
| 138 | +bool GrD3DCaps::onAreColorTypeAndFormatCompatible(GrColorType ct, |
| 139 | + const GrBackendFormat& format) const { |
| 140 | + // TODO |
| 141 | + return false; |
| 142 | +} |
| 143 | + |
| 144 | +GrColorType GrD3DCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& format, |
| 145 | + bool isAlphaChannel) const { |
| 146 | + // TODO |
| 147 | + return GrColorType::kUnknown; |
| 148 | +} |
| 149 | + |
| 150 | +GrBackendFormat GrD3DCaps::onGetDefaultBackendFormat(GrColorType ct, |
| 151 | + GrRenderable renderable) const { |
| 152 | + // TODO |
| 153 | + return GrBackendFormat(); |
| 154 | +} |
| 155 | + |
| 156 | +GrBackendFormat GrD3DCaps::getBackendFormatFromCompressionType( |
| 157 | + SkImage::CompressionType compressionType) const { |
| 158 | + // TODO |
| 159 | + return {}; |
| 160 | +} |
| 161 | + |
| 162 | +GrSwizzle GrD3DCaps::getReadSwizzle(const GrBackendFormat& format, GrColorType colorType) const { |
| 163 | + // TODO |
| 164 | + return GrSwizzle::RGBA(); |
| 165 | +} |
| 166 | + |
| 167 | +GrSwizzle GrD3DCaps::getOutputSwizzle(const GrBackendFormat& format, GrColorType colorType) const { |
| 168 | + // TODO |
| 169 | + return GrSwizzle::RGBA(); |
| 170 | +} |
| 171 | + |
| 172 | +uint64_t GrD3DCaps::computeFormatKey(const GrBackendFormat& format) const { |
| 173 | + // TODO |
| 174 | + return (uint64_t)0; |
| 175 | +} |
| 176 | + |
| 177 | +GrCaps::SupportedRead GrD3DCaps::onSupportedReadPixelsColorType( |
| 178 | + GrColorType srcColorType, const GrBackendFormat& srcBackendFormat, |
| 179 | + GrColorType dstColorType) const { |
| 180 | + // TODO |
| 181 | + return {GrColorType::kUnknown, 0}; |
| 182 | +} |
| 183 | + |
| 184 | +void GrD3DCaps::addExtraSamplerKey(GrProcessorKeyBuilder* b, |
| 185 | + GrSamplerState samplerState, |
| 186 | + const GrBackendFormat& format) const { |
| 187 | + // TODO |
| 188 | +} |
| 189 | + |
| 190 | +/** |
| 191 | + * TODO: Determin what goes in the ProgramDesc |
| 192 | + */ |
| 193 | +GrProgramDesc GrD3DCaps::makeDesc(const GrRenderTarget* rt, const GrProgramInfo& programInfo) const { |
| 194 | + GrProgramDesc desc; |
| 195 | + if (!GrProgramDesc::Build(&desc, rt, programInfo, *this)) { |
| 196 | + SkASSERT(!desc.isValid()); |
| 197 | + return desc; |
| 198 | + } |
| 199 | + |
| 200 | + GrProcessorKeyBuilder b(&desc.key()); |
| 201 | + |
| 202 | + // TODO: add D3D-specific information |
| 203 | + |
| 204 | + return desc; |
| 205 | +} |
| 206 | + |
| 207 | +#if GR_TEST_UTILS |
| 208 | +std::vector<GrCaps::TestFormatColorTypeCombination> GrD3DCaps::getTestingCombinations() const { |
| 209 | + std::vector<GrCaps::TestFormatColorTypeCombination> combos = { |
| 210 | + // TODO: fill in combos |
| 211 | + }; |
| 212 | + |
| 213 | + return combos; |
| 214 | +} |
| 215 | +#endif |
0 commit comments