MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MakeGlTexture

Function MakeGlTexture

tensorflow/lite/delegates/gpu/gl/runtime.cc:72–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70};
71
72Status MakeGlTexture(const Object& object, const ObjectData& data,
73 GlTexture* gl_texture) {
74 if (object.access == AccessType::READ_WRITE ||
75 object.access == AccessType::WRITE) {
76 return InvalidArgumentError("Read-write textures are not supported");
77 }
78 if (object.data_type != DataType::FLOAT16 &&
79 object.data_type != DataType::FLOAT32) {
80 return InvalidArgumentError("Textures support float16 or float32 only.");
81 }
82 switch (object.data_type) {
83 case DataType::FLOAT16: {
84 if (data.size() % 2 != 0) {
85 return InvalidArgumentError("Texture size is not aligned");
86 }
87 return absl::visit(
88 TextureF16Maker{
89 .data = absl::MakeConstSpan(
90 reinterpret_cast<const uint16_t*>(data.data()),
91 data.size() / 2),
92 .gl_texture = gl_texture,
93 },
94 object.size);
95 }
96 case DataType::FLOAT32: {
97 if (data.size() % sizeof(float) != 0) {
98 return InvalidArgumentError("Texture size is not aligned");
99 }
100 return absl::visit(
101 TextureF32Maker{
102 .data = absl::MakeConstSpan(
103 reinterpret_cast<const float*>(data.data()),
104 data.size() / sizeof(float)),
105 .gl_texture = gl_texture,
106 },
107 object.size);
108 }
109 default:
110 return InvalidArgumentError("Unsupported textures data type.");
111 }
112}
113
114struct TextureRefMaker {
115 Status operator()(const uint3& size) const {

Callers 1

AllocateConstObjectMethod · 0.85

Calls 4

InvalidArgumentErrorFunction · 0.50
visitFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected