2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "test-graphics-controller.h"
19 #include "test-graphics-buffer.h"
20 #include "test-graphics-command-buffer.h"
21 #include "test-graphics-reflection.h"
22 #include "test-graphics-sampler.h"
23 #include "test-graphics-shader.h"
24 #include "test-graphics-texture.h"
26 #include <dali/integration-api/gl-defines.h>
34 T* Uncast(const Graphics::CommandBuffer* object)
36 return const_cast<T*>(static_cast<const T*>(object));
40 T* Uncast(const Graphics::Texture* object)
42 return const_cast<T*>(static_cast<const T*>(object));
46 T* Uncast(const Graphics::Sampler* object)
48 return const_cast<T*>(static_cast<const T*>(object));
52 T* Uncast(const Graphics::Buffer* object)
54 return const_cast<T*>(static_cast<const T*>(object));
57 std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo)
59 return o << "usage:" << std::hex << bufferCreateInfo.usage << ", size:" << std::dec << bufferCreateInfo.size;
62 std::ostream& operator<<(std::ostream& o, const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo)
64 return o << "level:" << (commandBufferCreateInfo.level == Graphics::CommandBufferLevel::PRIMARY ? "PRIMARY" : "SECONDARY")
65 << ", fixedCapacity:" << std::dec << commandBufferCreateInfo.fixedCapacity;
68 std::ostream& operator<<(std::ostream& o, const Graphics::TextureType& textureType)
72 case Graphics::TextureType::TEXTURE_2D:
75 case Graphics::TextureType::TEXTURE_3D:
78 case Graphics::TextureType::TEXTURE_CUBEMAP:
79 o << "TEXTURE_CUBEMAP";
85 std::ostream& operator<<(std::ostream& o, const Graphics::Extent2D extent)
87 o << "width:" << extent.width << ", height:" << extent.height;
91 std::ostream& operator<<(std::ostream& o, const Graphics::TextureCreateInfo& createInfo)
93 o << "textureType:" << createInfo.textureType
94 << " size:" << createInfo.size
95 << " format:" << static_cast<uint32_t>(createInfo.format)
96 << " mipMapFlag:" << createInfo.mipMapFlag
97 << " layout:" << (createInfo.layout == Graphics::TextureLayout::LINEAR ? "LINEAR" : "OPTIMAL")
98 << " usageFlags:" << std::hex << createInfo.usageFlags
99 << " data:" << std::hex << createInfo.data
100 << " dataSize:" << std::dec << createInfo.dataSize
101 << " nativeImagePtr:" << std::hex << createInfo.nativeImagePtr;
105 std::ostream& operator<<(std::ostream& o, Graphics::SamplerAddressMode addressMode)
109 case Graphics::SamplerAddressMode::REPEAT:
112 case Graphics::SamplerAddressMode::MIRRORED_REPEAT:
113 o << "MIRRORED_REPEAT";
115 case Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
116 o << "CLAMP_TO_EDGE";
118 case Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
119 o << "CLAMP_TO_BORDER";
121 case Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
122 o << "MIRROR_CLAMP_TO_EDGE";
128 std::ostream& operator<<(std::ostream& o, Graphics::SamplerFilter filterMode)
132 case Graphics::SamplerFilter::LINEAR:
135 case Graphics::SamplerFilter::NEAREST:
142 std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode)
146 case Graphics::SamplerMipmapMode::NONE:
149 case Graphics::SamplerMipmapMode::LINEAR:
152 case Graphics::SamplerMipmapMode::NEAREST:
159 std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo)
161 o << "minFilter:" << createInfo.minFilter
162 << " magFilter:" << createInfo.magFilter
163 << " wrapModeU:" << createInfo.addressModeU
164 << " wrapModeV:" << createInfo.addressModeV
165 << " wrapModeW:" << createInfo.addressModeW
166 << " mipMapMode:" << createInfo.mipMapMode;
170 class TestGraphicsMemory : public Graphics::Memory
173 TestGraphicsMemory(TraceCallStack& callStack, TestGraphicsBuffer& buffer, uint32_t mappedOffset, uint32_t mappedSize)
174 : mCallStack(callStack),
176 mMappedOffset(mappedOffset),
177 mMappedSize(mappedSize)
181 void* LockRegion(uint32_t offset, uint32_t size) override
183 std::ostringstream o;
184 o << offset << ", " << size;
185 mCallStack.PushCall("Memory::LockRegion", o.str());
187 if(offset > mMappedOffset + mMappedSize ||
188 size + offset > mMappedOffset + mMappedSize)
190 fprintf(stderr, "TestGraphics.Memory::LockRegion() Out of bounds");
191 mBuffer.memory.resize(mMappedOffset + offset + size); // Grow to prevent memcpy from crashing
193 mLockedOffset = offset;
195 return &mBuffer.memory[mMappedOffset + offset];
198 void Unlock(bool flush) override
200 mCallStack.PushCall("Memory::Unlock", (flush ? "Flush" : "NoFlush"));
207 void Flush() override
209 mCallStack.PushCall("Memory::Flush", "");
211 mBuffer.Upload(mMappedOffset + mLockedOffset, mLockedSize);
215 TraceCallStack& mCallStack;
216 TestGraphicsBuffer& mBuffer;
217 uint32_t mMappedOffset;
218 uint32_t mMappedSize;
219 uint32_t mLockedOffset;
220 uint32_t mLockedSize;
223 TestGraphicsController::TestGraphicsController()
224 : mCallStack(true, "TestGraphicsController."),
225 mCommandBufferCallStack(true, "TestCommandBuffer.")
227 mCallStack.Enable(true);
228 mCommandBufferCallStack.Enable(true);
229 auto& trace = mGl.GetTextureTrace();
231 trace.EnableLogging(true);
234 int GetNumComponents(Graphics::VertexInputFormat vertexFormat)
238 case Graphics::VertexInputFormat::UNDEFINED:
239 case Graphics::VertexInputFormat::FLOAT:
240 case Graphics::VertexInputFormat::INTEGER:
242 case Graphics::VertexInputFormat::IVECTOR2:
243 case Graphics::VertexInputFormat::FVECTOR2:
245 case Graphics::VertexInputFormat::IVECTOR3:
246 case Graphics::VertexInputFormat::FVECTOR3:
248 case Graphics::VertexInputFormat::FVECTOR4:
249 case Graphics::VertexInputFormat::IVECTOR4:
255 GLint GetSize(Graphics::VertexInputFormat vertexFormat)
259 case Graphics::VertexInputFormat::UNDEFINED:
261 case Graphics::VertexInputFormat::INTEGER:
262 case Graphics::VertexInputFormat::IVECTOR2:
263 case Graphics::VertexInputFormat::IVECTOR3:
264 case Graphics::VertexInputFormat::IVECTOR4:
266 case Graphics::VertexInputFormat::FLOAT:
267 case Graphics::VertexInputFormat::FVECTOR2:
268 case Graphics::VertexInputFormat::FVECTOR3:
269 case Graphics::VertexInputFormat::FVECTOR4:
275 GLint GetGlType(Graphics::VertexInputFormat vertexFormat)
279 case Graphics::VertexInputFormat::UNDEFINED:
281 case Graphics::VertexInputFormat::INTEGER:
282 case Graphics::VertexInputFormat::IVECTOR2:
283 case Graphics::VertexInputFormat::IVECTOR3:
284 case Graphics::VertexInputFormat::IVECTOR4:
286 case Graphics::VertexInputFormat::FLOAT:
287 case Graphics::VertexInputFormat::FVECTOR2:
288 case Graphics::VertexInputFormat::FVECTOR3:
289 case Graphics::VertexInputFormat::FVECTOR4:
295 GLenum GetTopology(Graphics::PrimitiveTopology topology)
299 case Graphics::PrimitiveTopology::POINT_LIST:
302 case Graphics::PrimitiveTopology::LINE_LIST:
305 case Graphics::PrimitiveTopology::LINE_LOOP:
308 case Graphics::PrimitiveTopology::LINE_STRIP:
309 return GL_LINE_STRIP;
311 case Graphics::PrimitiveTopology::TRIANGLE_LIST:
314 case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
315 return GL_TRIANGLE_STRIP;
317 case Graphics::PrimitiveTopology::TRIANGLE_FAN:
318 return GL_TRIANGLE_FAN;
323 GLenum GetCullFace(Graphics::CullMode cullMode)
327 case Graphics::CullMode::NONE:
329 case Graphics::CullMode::FRONT:
331 case Graphics::CullMode::BACK:
333 case Graphics::CullMode::FRONT_AND_BACK:
334 return GL_FRONT_AND_BACK;
339 GLenum GetFrontFace(Graphics::FrontFace frontFace)
341 if(frontFace == Graphics::FrontFace::CLOCKWISE)
348 GLenum GetBlendFactor(Graphics::BlendFactor blendFactor)
350 GLenum glFactor = GL_ZERO;
354 case Graphics::BlendFactor::ZERO:
357 case Graphics::BlendFactor::ONE:
360 case Graphics::BlendFactor::SRC_COLOR:
361 glFactor = GL_SRC_COLOR;
363 case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
364 glFactor = GL_ONE_MINUS_SRC_COLOR;
366 case Graphics::BlendFactor::DST_COLOR:
367 glFactor = GL_DST_COLOR;
369 case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
370 glFactor = GL_ONE_MINUS_DST_COLOR;
372 case Graphics::BlendFactor::SRC_ALPHA:
373 glFactor = GL_SRC_ALPHA;
375 case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
376 glFactor = GL_ONE_MINUS_SRC_ALPHA;
378 case Graphics::BlendFactor::DST_ALPHA:
379 glFactor = GL_DST_ALPHA;
381 case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
382 glFactor = GL_ONE_MINUS_DST_ALPHA;
384 case Graphics::BlendFactor::CONSTANT_COLOR:
385 glFactor = GL_CONSTANT_COLOR;
387 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
388 glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
390 case Graphics::BlendFactor::CONSTANT_ALPHA:
391 glFactor = GL_CONSTANT_ALPHA;
393 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
394 glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
396 case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
397 glFactor = GL_SRC_ALPHA_SATURATE;
399 // GLES doesn't appear to have dual source blending.
400 case Graphics::BlendFactor::SRC1_COLOR:
401 glFactor = GL_SRC_COLOR;
403 case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
404 glFactor = GL_ONE_MINUS_SRC_COLOR;
406 case Graphics::BlendFactor::SRC1_ALPHA:
407 glFactor = GL_SRC_ALPHA;
409 case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
410 glFactor = GL_ONE_MINUS_SRC_ALPHA;
416 GLenum GetBlendOp(Graphics::BlendOp blendOp)
418 GLenum op = GL_FUNC_ADD;
421 case Graphics::BlendOp::ADD:
424 case Graphics::BlendOp::SUBTRACT:
425 op = GL_FUNC_SUBTRACT;
427 case Graphics::BlendOp::REVERSE_SUBTRACT:
428 op = GL_FUNC_REVERSE_SUBTRACT;
430 case Graphics::BlendOp::MIN:
433 case Graphics::BlendOp::MAX:
437 // @todo Add advanced blend equations
442 void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
444 TraceCallStack::NamedParams namedParams;
445 namedParams["submitInfo"] << "cmdBuffer[" << submitInfo.cmdBuffer.size()
446 << "], flags:" << std::hex << submitInfo.flags;
448 mCallStack.PushCall("SubmitCommandBuffers", "", namedParams);
450 mSubmitStack.emplace_back(submitInfo);
452 for(auto& graphicsCommandBuffer : submitInfo.cmdBuffer)
454 auto commandBuffer = Uncast<TestGraphicsCommandBuffer>(graphicsCommandBuffer);
455 for(auto& binding : commandBuffer->mTextureBindings)
459 auto texture = Uncast<TestGraphicsTexture>(binding.texture);
461 texture->Bind(binding.binding);
465 auto sampler = Uncast<TestGraphicsSampler>(binding.sampler);
468 sampler->Apply(texture->GetTarget());
472 texture->Prepare(); // Ensure native texture is ready
476 // IndexBuffer binding,
477 auto& indexBufferBinding = commandBuffer->mIndexBufferBinding;
478 if(indexBufferBinding.buffer)
480 auto buffer = Uncast<TestGraphicsBuffer>(indexBufferBinding.buffer);
484 // VertexBuffer binding,
485 for(auto graphicsBuffer : commandBuffer->mVertexBufferBindings.buffers)
487 auto vertexBuffer = Uncast<TestGraphicsBuffer>(graphicsBuffer);
488 vertexBuffer->Bind();
491 // Pipeline attribute setup
492 auto& vi = commandBuffer->mPipeline->vertexInputState;
493 for(auto& attribute : vi.attributes)
495 mGl.EnableVertexAttribArray(attribute.location);
496 uint32_t attributeOffset = attribute.offset;
497 GLsizei stride = vi.bufferBindings[attribute.binding].stride;
499 mGl.VertexAttribPointer(attribute.location,
500 GetNumComponents(attribute.format),
501 GetGlType(attribute.format),
502 GL_FALSE, // Not normalized
504 reinterpret_cast<void*>(attributeOffset));
508 auto& rasterizationState = commandBuffer->mPipeline->rasterizationState;
509 if(rasterizationState.cullMode == Graphics::CullMode::NONE)
511 mGl.Disable(GL_CULL_FACE);
515 mGl.Enable(GL_CULL_FACE);
516 mGl.CullFace(GetCullFace(rasterizationState.cullMode));
519 mGl.FrontFace(GetFrontFace(rasterizationState.frontFace));
520 // We don't modify glPolygonMode in our context/abstraction from GL_FILL (the GL default),
521 // so it isn't present in the API (and won't have any tests!)
524 auto& colorBlendState = commandBuffer->mPipeline->colorBlendState;
525 if(colorBlendState.blendEnable)
527 mGl.Enable(GL_BLEND);
529 mGl.BlendFuncSeparate(GetBlendFactor(colorBlendState.srcColorBlendFactor),
530 GetBlendFactor(colorBlendState.dstColorBlendFactor),
531 GetBlendFactor(colorBlendState.srcAlphaBlendFactor),
532 GetBlendFactor(colorBlendState.dstAlphaBlendFactor));
533 if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
535 mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp));
539 mGl.BlendEquation(GetBlendOp(colorBlendState.colorBlendOp));
541 mGl.BlendColor(colorBlendState.blendConstants[0],
542 colorBlendState.blendConstants[1],
543 colorBlendState.blendConstants[2],
544 colorBlendState.blendConstants[3]);
548 mGl.Disable(GL_BLEND);
552 auto topology = commandBuffer->mPipeline->inputAssemblyState.topology;
554 if(commandBuffer->drawCommand.drawType == TestGraphicsCommandBuffer::Draw::DrawType::Indexed)
556 mGl.DrawElements(GetTopology(topology),
557 static_cast<GLsizei>(commandBuffer->drawCommand.u.indexedDraw.indexCount),
559 reinterpret_cast<void*>(commandBuffer->drawCommand.u.indexedDraw.firstIndex));
563 mGl.DrawArrays(GetTopology(topology), 0, commandBuffer->drawCommand.u.unindexedDraw.vertexCount);
567 for(auto& attribute : vi.attributes)
569 mGl.DisableVertexAttribArray(attribute.location);
575 * @brief Presents render target
576 * @param renderTarget render target to present
578 void TestGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget)
580 TraceCallStack::NamedParams namedParams;
581 namedParams["renderTarget"] << std::hex << renderTarget;
582 mCallStack.PushCall("PresentRenderTarget", "", namedParams);
586 * @brief Waits until the GPU is idle
588 void TestGraphicsController::WaitIdle()
590 mCallStack.PushCall("WaitIdle", "");
594 * @brief Lifecycle pause event
596 void TestGraphicsController::Pause()
598 mCallStack.PushCall("Pause", "");
602 * @brief Lifecycle resume event
604 void TestGraphicsController::Resume()
606 mCallStack.PushCall("Resume", "");
609 void TestGraphicsController::UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>& updateInfoList,
610 const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList)
612 TraceCallStack::NamedParams namedParams;
613 namedParams["updateInfoList"] << "[" << updateInfoList.size() << "]:";
614 namedParams["sourceList"] << "[" << sourceList.size() << "]:";
616 mCallStack.PushCall("UpdateTextures", "", namedParams);
618 // Call either TexImage2D or TexSubImage2D
619 for(unsigned int i = 0; i < updateInfoList.size(); ++i)
621 auto& updateInfo = updateInfoList[i];
622 auto& source = sourceList[i];
624 auto texture = static_cast<TestGraphicsTexture*>(updateInfo.dstTexture);
625 texture->Bind(0); // Use first texture unit during resource update
626 texture->Update(updateInfo, source);
630 bool TestGraphicsController::EnableDepthStencilBuffer(bool enableDepth, bool enableStencil)
632 TraceCallStack::NamedParams namedParams;
633 namedParams["enableDepth"] << (enableDepth ? "T" : "F");
634 namedParams["enableStencil"] << (enableStencil ? "T" : "F");
635 mCallStack.PushCall("EnableDepthStencilBuffer", "", namedParams);
639 void TestGraphicsController::RunGarbageCollector(size_t numberOfDiscardedRenderers)
641 TraceCallStack::NamedParams namedParams;
642 namedParams["numberOfDiscardedRenderers"] << numberOfDiscardedRenderers;
643 mCallStack.PushCall("RunGarbageCollector", "", namedParams);
646 void TestGraphicsController::DiscardUnusedResources()
648 mCallStack.PushCall("DiscardUnusedResources", "");
651 bool TestGraphicsController::IsDiscardQueueEmpty()
653 mCallStack.PushCall("IsDiscardQueueEmpty", "");
654 return isDiscardQueueEmptyResult;
658 * @brief Test if the graphics subsystem has resumed & should force a draw
660 * @return true if the graphics subsystem requires a re-draw
662 bool TestGraphicsController::IsDrawOnResumeRequired()
664 mCallStack.PushCall("IsDrawOnResumeRequired", "");
665 return isDrawOnResumeRequiredResult;
668 Graphics::UniquePtr<Graphics::Buffer> TestGraphicsController::CreateBuffer(const Graphics::BufferCreateInfo& createInfo, Graphics::UniquePtr<Graphics::Buffer>&& oldBuffer)
670 std::ostringstream oss;
671 oss << "bufferCreateInfo:" << createInfo;
672 mCallStack.PushCall("CreateBuffer", oss.str());
673 return Graphics::MakeUnique<TestGraphicsBuffer>(mCallStack, mGl, createInfo.size, createInfo.usage);
676 Graphics::UniquePtr<Graphics::CommandBuffer> TestGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer)
678 std::ostringstream oss;
679 oss << "commandBufferCreateInfo:" << commandBufferCreateInfo;
680 mCallStack.PushCall("CreateCommandBuffer", oss.str());
681 return Graphics::MakeUnique<TestGraphicsCommandBuffer>(mCommandBufferCallStack, mGl);
684 Graphics::UniquePtr<Graphics::RenderPass> TestGraphicsController::CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<Graphics::RenderPass>&& oldRenderPass)
686 mCallStack.PushCall("CreateRenderPass", "");
690 Graphics::UniquePtr<Graphics::Texture> TestGraphicsController::CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Graphics::Texture>&& oldTexture)
692 TraceCallStack::NamedParams namedParams;
693 namedParams["textureCreateInfo"] << textureCreateInfo;
694 mCallStack.PushCall("CreateTexture", namedParams.str(), namedParams);
696 return Graphics::MakeUnique<TestGraphicsTexture>(mGl, textureCreateInfo);
699 Graphics::UniquePtr<Graphics::Framebuffer> TestGraphicsController::CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr<Graphics::Framebuffer>&& oldFramebuffer)
701 mCallStack.PushCall("CreateFramebuffer", "");
705 Graphics::UniquePtr<Graphics::Pipeline> TestGraphicsController::CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
707 mCallStack.PushCall("CreatePipeline", "");
708 return std::make_unique<TestGraphicsPipeline>(mGl, pipelineCreateInfo);
711 Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(const Graphics::ProgramCreateInfo& programCreateInfo, Graphics::UniquePtr<Graphics::Program>&& oldProgram)
713 mCallStack.PushCall("CreateProgram", "");
714 return Graphics::MakeUnique<TestGraphicsProgram>(mGl, programCreateInfo, mVertexFormats);
717 Graphics::UniquePtr<Graphics::Shader> TestGraphicsController::CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Graphics::Shader>&& oldShader)
719 mCallStack.PushCall("CreateShader", "");
720 return Graphics::MakeUnique<TestGraphicsShader>(mGl, shaderCreateInfo);
723 Graphics::UniquePtr<Graphics::Sampler> TestGraphicsController::CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Graphics::Sampler>&& oldSampler)
725 TraceCallStack::NamedParams namedParams;
726 namedParams["samplerCreateInfo"] << samplerCreateInfo;
727 mCallStack.PushCall("CreateSampler", namedParams.str(), namedParams);
729 return Graphics::MakeUnique<TestGraphicsSampler>(mGl, samplerCreateInfo);
732 Graphics::UniquePtr<Graphics::RenderTarget> TestGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget)
734 mCallStack.PushCall("CreateRenderTarget", "");
738 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapBufferRange(const Graphics::MapBufferInfo& mapInfo)
740 mCallStack.PushCall("MapBufferRange", "");
742 auto buffer = static_cast<TestGraphicsBuffer*>(mapInfo.buffer);
743 buffer->memory.resize(mapInfo.offset + mapInfo.size); // For initial testing, allow writes past capacity
745 return std::make_unique<TestGraphicsMemory>(mCallStack, *buffer, mapInfo.offset, mapInfo.size);
748 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapTextureRange(const Graphics::MapTextureInfo& mapInfo)
750 mCallStack.PushCall("MapTextureRange", "");
754 void TestGraphicsController::UnmapMemory(Graphics::UniquePtr<Graphics::Memory> memory)
756 mCallStack.PushCall("UnmapMemory", "");
759 Graphics::MemoryRequirements TestGraphicsController::GetTextureMemoryRequirements(Graphics::Texture& texture) const
761 mCallStack.PushCall("GetTextureMemoryRequirements", "");
762 return Graphics::MemoryRequirements{};
765 Graphics::MemoryRequirements TestGraphicsController::GetBufferMemoryRequirements(Graphics::Buffer& buffer) const
767 mCallStack.PushCall("GetBufferMemoryRequirements", "");
768 return Graphics::MemoryRequirements{};
771 const Graphics::TextureProperties& TestGraphicsController::GetTextureProperties(const Graphics::Texture& texture)
773 static Graphics::TextureProperties textureProperties{};
774 mCallStack.PushCall("GetTextureProperties", "");
776 return textureProperties;
779 const Graphics::Reflection& TestGraphicsController::GetProgramReflection(const Graphics::Program& program)
781 mCallStack.PushCall("GetProgramReflection", "");
783 return static_cast<const TestGraphicsProgram*>(&program)->GetReflection();
786 bool TestGraphicsController::PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const
788 mCallStack.PushCall("PipelineEquals", "");
792 bool TestGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData )
794 mCallStack.PushCall("GetProgramParameter", "");
795 auto graphicsProgram = Uncast<TestGraphicsProgram>(&program);
796 return graphicsProgram->GetParameter(parameterId, outData);