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-program.h"
25 #include "test-graphics-texture.h"
27 #include <dali/integration-api/gl-defines.h>
35 T* Uncast(const Graphics::CommandBuffer* object)
37 return const_cast<T*>(static_cast<const T*>(object));
41 T* Uncast(const Graphics::Texture* object)
43 return const_cast<T*>(static_cast<const T*>(object));
47 T* Uncast(const Graphics::Sampler* object)
49 return const_cast<T*>(static_cast<const T*>(object));
53 T* Uncast(const Graphics::Buffer* object)
55 return const_cast<T*>(static_cast<const T*>(object));
58 std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo)
60 return o << "usage:" << std::hex << bufferCreateInfo.usage << ", size:" << std::dec << bufferCreateInfo.size;
63 std::ostream& operator<<(std::ostream& o, const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo)
65 return o << "level:" << (commandBufferCreateInfo.level == Graphics::CommandBufferLevel::PRIMARY ? "PRIMARY" : "SECONDARY")
66 << ", fixedCapacity:" << std::dec << commandBufferCreateInfo.fixedCapacity;
69 std::ostream& operator<<(std::ostream& o, const Graphics::TextureType& textureType)
73 case Graphics::TextureType::TEXTURE_2D:
76 case Graphics::TextureType::TEXTURE_3D:
79 case Graphics::TextureType::TEXTURE_CUBEMAP:
80 o << "TEXTURE_CUBEMAP";
86 std::ostream& operator<<(std::ostream& o, const Graphics::Extent2D extent)
88 o << "width:" << extent.width << ", height:" << extent.height;
92 std::ostream& operator<<(std::ostream& o, const Graphics::TextureCreateInfo& createInfo)
94 o << "textureType:" << createInfo.textureType
95 << " size:" << createInfo.size
96 << " format:" << static_cast<uint32_t>(createInfo.format)
97 << " mipMapFlag:" << createInfo.mipMapFlag
98 << " layout:" << (createInfo.layout == Graphics::TextureLayout::LINEAR ? "LINEAR" : "OPTIMAL")
99 << " usageFlags:" << std::hex << createInfo.usageFlags
100 << " data:" << std::hex << createInfo.data
101 << " dataSize:" << std::dec << createInfo.dataSize
102 << " nativeImagePtr:" << std::hex << createInfo.nativeImagePtr;
106 std::ostream& operator<<(std::ostream& o, Graphics::SamplerAddressMode addressMode)
110 case Graphics::SamplerAddressMode::REPEAT:
113 case Graphics::SamplerAddressMode::MIRRORED_REPEAT:
114 o << "MIRRORED_REPEAT";
116 case Graphics::SamplerAddressMode::CLAMP_TO_EDGE:
117 o << "CLAMP_TO_EDGE";
119 case Graphics::SamplerAddressMode::CLAMP_TO_BORDER:
120 o << "CLAMP_TO_BORDER";
122 case Graphics::SamplerAddressMode::MIRROR_CLAMP_TO_EDGE:
123 o << "MIRROR_CLAMP_TO_EDGE";
129 std::ostream& operator<<(std::ostream& o, Graphics::SamplerFilter filterMode)
133 case Graphics::SamplerFilter::LINEAR:
136 case Graphics::SamplerFilter::NEAREST:
143 std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode)
147 case Graphics::SamplerMipmapMode::NONE:
150 case Graphics::SamplerMipmapMode::LINEAR:
153 case Graphics::SamplerMipmapMode::NEAREST:
160 std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo)
162 o << "minFilter:" << createInfo.minFilter
163 << " magFilter:" << createInfo.magFilter
164 << " wrapModeU:" << createInfo.addressModeU
165 << " wrapModeV:" << createInfo.addressModeV
166 << " wrapModeW:" << createInfo.addressModeW
167 << " mipMapMode:" << createInfo.mipMapMode;
171 class TestGraphicsMemory : public Graphics::Memory
174 TestGraphicsMemory(TraceCallStack& callStack, TestGraphicsBuffer& buffer, uint32_t mappedOffset, uint32_t mappedSize)
175 : mCallStack(callStack),
177 mMappedOffset(mappedOffset),
178 mMappedSize(mappedSize)
182 void* LockRegion(uint32_t offset, uint32_t size) override
184 std::ostringstream o;
185 o << offset << ", " << size;
186 mCallStack.PushCall("Memory::LockRegion", o.str());
188 if(offset > mMappedOffset + mMappedSize ||
189 size + offset > mMappedOffset + mMappedSize)
191 fprintf(stderr, "TestGraphics.Memory::LockRegion() Out of bounds");
192 mBuffer.memory.resize(mMappedOffset + offset + size); // Grow to prevent memcpy from crashing
194 mLockedOffset = offset;
196 return &mBuffer.memory[mMappedOffset + offset];
199 void Unlock(bool flush) override
201 mCallStack.PushCall("Memory::Unlock", (flush ? "Flush" : "NoFlush"));
208 void Flush() override
210 mCallStack.PushCall("Memory::Flush", "");
212 mBuffer.Upload(mMappedOffset + mLockedOffset, mLockedSize);
216 TraceCallStack& mCallStack;
217 TestGraphicsBuffer& mBuffer;
218 uint32_t mMappedOffset;
219 uint32_t mMappedSize;
220 uint32_t mLockedOffset;
221 uint32_t mLockedSize;
224 TestGraphicsController::TestGraphicsController()
225 : mCallStack(true, "TestGraphicsController."),
226 mCommandBufferCallStack(true, "TestCommandBuffer.")
228 mCallStack.Enable(true);
229 mCommandBufferCallStack.Enable(true);
230 auto& trace = mGl.GetTextureTrace();
232 trace.EnableLogging(true);
235 int GetNumComponents(Graphics::VertexInputFormat vertexFormat)
239 case Graphics::VertexInputFormat::UNDEFINED:
240 case Graphics::VertexInputFormat::FLOAT:
241 case Graphics::VertexInputFormat::INTEGER:
243 case Graphics::VertexInputFormat::IVECTOR2:
244 case Graphics::VertexInputFormat::FVECTOR2:
246 case Graphics::VertexInputFormat::IVECTOR3:
247 case Graphics::VertexInputFormat::FVECTOR3:
249 case Graphics::VertexInputFormat::FVECTOR4:
250 case Graphics::VertexInputFormat::IVECTOR4:
256 GLint GetSize(Graphics::VertexInputFormat vertexFormat)
260 case Graphics::VertexInputFormat::UNDEFINED:
262 case Graphics::VertexInputFormat::INTEGER:
263 case Graphics::VertexInputFormat::IVECTOR2:
264 case Graphics::VertexInputFormat::IVECTOR3:
265 case Graphics::VertexInputFormat::IVECTOR4:
267 case Graphics::VertexInputFormat::FLOAT:
268 case Graphics::VertexInputFormat::FVECTOR2:
269 case Graphics::VertexInputFormat::FVECTOR3:
270 case Graphics::VertexInputFormat::FVECTOR4:
276 GLint GetGlType(Graphics::VertexInputFormat vertexFormat)
280 case Graphics::VertexInputFormat::UNDEFINED:
282 case Graphics::VertexInputFormat::INTEGER:
283 case Graphics::VertexInputFormat::IVECTOR2:
284 case Graphics::VertexInputFormat::IVECTOR3:
285 case Graphics::VertexInputFormat::IVECTOR4:
287 case Graphics::VertexInputFormat::FLOAT:
288 case Graphics::VertexInputFormat::FVECTOR2:
289 case Graphics::VertexInputFormat::FVECTOR3:
290 case Graphics::VertexInputFormat::FVECTOR4:
296 GLenum GetTopology(Graphics::PrimitiveTopology topology)
300 case Graphics::PrimitiveTopology::POINT_LIST:
303 case Graphics::PrimitiveTopology::LINE_LIST:
306 case Graphics::PrimitiveTopology::LINE_LOOP:
309 case Graphics::PrimitiveTopology::LINE_STRIP:
310 return GL_LINE_STRIP;
312 case Graphics::PrimitiveTopology::TRIANGLE_LIST:
315 case Graphics::PrimitiveTopology::TRIANGLE_STRIP:
316 return GL_TRIANGLE_STRIP;
318 case Graphics::PrimitiveTopology::TRIANGLE_FAN:
319 return GL_TRIANGLE_FAN;
324 GLenum GetCullFace(Graphics::CullMode cullMode)
328 case Graphics::CullMode::NONE:
330 case Graphics::CullMode::FRONT:
332 case Graphics::CullMode::BACK:
334 case Graphics::CullMode::FRONT_AND_BACK:
335 return GL_FRONT_AND_BACK;
340 GLenum GetFrontFace(Graphics::FrontFace frontFace)
342 if(frontFace == Graphics::FrontFace::CLOCKWISE)
349 GLenum GetBlendFactor(Graphics::BlendFactor blendFactor)
351 GLenum glFactor = GL_ZERO;
355 case Graphics::BlendFactor::ZERO:
358 case Graphics::BlendFactor::ONE:
361 case Graphics::BlendFactor::SRC_COLOR:
362 glFactor = GL_SRC_COLOR;
364 case Graphics::BlendFactor::ONE_MINUS_SRC_COLOR:
365 glFactor = GL_ONE_MINUS_SRC_COLOR;
367 case Graphics::BlendFactor::DST_COLOR:
368 glFactor = GL_DST_COLOR;
370 case Graphics::BlendFactor::ONE_MINUS_DST_COLOR:
371 glFactor = GL_ONE_MINUS_DST_COLOR;
373 case Graphics::BlendFactor::SRC_ALPHA:
374 glFactor = GL_SRC_ALPHA;
376 case Graphics::BlendFactor::ONE_MINUS_SRC_ALPHA:
377 glFactor = GL_ONE_MINUS_SRC_ALPHA;
379 case Graphics::BlendFactor::DST_ALPHA:
380 glFactor = GL_DST_ALPHA;
382 case Graphics::BlendFactor::ONE_MINUS_DST_ALPHA:
383 glFactor = GL_ONE_MINUS_DST_ALPHA;
385 case Graphics::BlendFactor::CONSTANT_COLOR:
386 glFactor = GL_CONSTANT_COLOR;
388 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_COLOR:
389 glFactor = GL_ONE_MINUS_CONSTANT_COLOR;
391 case Graphics::BlendFactor::CONSTANT_ALPHA:
392 glFactor = GL_CONSTANT_ALPHA;
394 case Graphics::BlendFactor::ONE_MINUS_CONSTANT_ALPHA:
395 glFactor = GL_ONE_MINUS_CONSTANT_ALPHA;
397 case Graphics::BlendFactor::SRC_ALPHA_SATURATE:
398 glFactor = GL_SRC_ALPHA_SATURATE;
400 // GLES doesn't appear to have dual source blending.
401 case Graphics::BlendFactor::SRC1_COLOR:
402 glFactor = GL_SRC_COLOR;
404 case Graphics::BlendFactor::ONE_MINUS_SRC1_COLOR:
405 glFactor = GL_ONE_MINUS_SRC_COLOR;
407 case Graphics::BlendFactor::SRC1_ALPHA:
408 glFactor = GL_SRC_ALPHA;
410 case Graphics::BlendFactor::ONE_MINUS_SRC1_ALPHA:
411 glFactor = GL_ONE_MINUS_SRC_ALPHA;
417 GLenum GetBlendOp(Graphics::BlendOp blendOp)
419 GLenum op = GL_FUNC_ADD;
422 case Graphics::BlendOp::ADD:
425 case Graphics::BlendOp::SUBTRACT:
426 op = GL_FUNC_SUBTRACT;
428 case Graphics::BlendOp::REVERSE_SUBTRACT:
429 op = GL_FUNC_REVERSE_SUBTRACT;
431 case Graphics::BlendOp::MIN:
434 case Graphics::BlendOp::MAX:
438 // @todo Add advanced blend equations
443 void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo)
445 TraceCallStack::NamedParams namedParams;
446 namedParams["submitInfo"] << "cmdBuffer[" << submitInfo.cmdBuffer.size()
447 << "], flags:" << std::hex << submitInfo.flags;
449 mCallStack.PushCall("SubmitCommandBuffers", "", namedParams);
451 mSubmitStack.emplace_back(submitInfo);
453 for(auto& graphicsCommandBuffer : submitInfo.cmdBuffer)
455 auto commandBuffer = Uncast<TestGraphicsCommandBuffer>(graphicsCommandBuffer);
456 for(auto& binding : commandBuffer->mTextureBindings)
460 auto texture = Uncast<TestGraphicsTexture>(binding.texture);
462 texture->Bind(binding.binding);
466 auto sampler = Uncast<TestGraphicsSampler>(binding.sampler);
469 sampler->Apply(texture->GetTarget());
473 texture->Prepare(); // Ensure native texture is ready
477 // IndexBuffer binding,
478 auto& indexBufferBinding = commandBuffer->mIndexBufferBinding;
479 if(indexBufferBinding.buffer)
481 auto buffer = Uncast<TestGraphicsBuffer>(indexBufferBinding.buffer);
485 // VertexBuffer binding,
486 for(auto graphicsBuffer : commandBuffer->mVertexBufferBindings.buffers)
488 auto vertexBuffer = Uncast<TestGraphicsBuffer>(graphicsBuffer);
489 vertexBuffer->Bind();
492 // Pipeline attribute setup
493 auto& vi = commandBuffer->mPipeline->vertexInputState;
494 for(auto& attribute : vi.attributes)
496 mGl.EnableVertexAttribArray(attribute.location);
497 uint32_t attributeOffset = attribute.offset;
498 GLsizei stride = vi.bufferBindings[attribute.binding].stride;
500 mGl.VertexAttribPointer(attribute.location,
501 GetNumComponents(attribute.format),
502 GetGlType(attribute.format),
503 GL_FALSE, // Not normalized
505 reinterpret_cast<void*>(attributeOffset));
509 auto& rasterizationState = commandBuffer->mPipeline->rasterizationState;
510 if(rasterizationState.cullMode == Graphics::CullMode::NONE)
512 mGl.Disable(GL_CULL_FACE);
516 mGl.Enable(GL_CULL_FACE);
517 mGl.CullFace(GetCullFace(rasterizationState.cullMode));
520 mGl.FrontFace(GetFrontFace(rasterizationState.frontFace));
521 // We don't modify glPolygonMode in our context/abstraction from GL_FILL (the GL default),
522 // so it isn't present in the API (and won't have any tests!)
525 auto& colorBlendState = commandBuffer->mPipeline->colorBlendState;
526 if(colorBlendState.blendEnable)
528 mGl.Enable(GL_BLEND);
530 mGl.BlendFuncSeparate(GetBlendFactor(colorBlendState.srcColorBlendFactor),
531 GetBlendFactor(colorBlendState.dstColorBlendFactor),
532 GetBlendFactor(colorBlendState.srcAlphaBlendFactor),
533 GetBlendFactor(colorBlendState.dstAlphaBlendFactor));
534 if(colorBlendState.colorBlendOp != colorBlendState.alphaBlendOp)
536 mGl.BlendEquationSeparate(GetBlendOp(colorBlendState.colorBlendOp), GetBlendOp(colorBlendState.alphaBlendOp));
540 mGl.BlendEquation(GetBlendOp(colorBlendState.colorBlendOp));
542 mGl.BlendColor(colorBlendState.blendConstants[0],
543 colorBlendState.blendConstants[1],
544 colorBlendState.blendConstants[2],
545 colorBlendState.blendConstants[3]);
549 mGl.Disable(GL_BLEND);
553 auto topology = commandBuffer->mPipeline->inputAssemblyState.topology;
555 if(commandBuffer->drawCommand.drawType == TestGraphicsCommandBuffer::Draw::DrawType::Indexed)
557 mGl.DrawElements(GetTopology(topology),
558 static_cast<GLsizei>(commandBuffer->drawCommand.u.indexedDraw.indexCount),
560 reinterpret_cast<void*>(commandBuffer->drawCommand.u.indexedDraw.firstIndex));
564 mGl.DrawArrays(GetTopology(topology), 0, commandBuffer->drawCommand.u.unindexedDraw.vertexCount);
568 for(auto& attribute : vi.attributes)
570 mGl.DisableVertexAttribArray(attribute.location);
576 * @brief Presents render target
577 * @param renderTarget render target to present
579 void TestGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget)
581 TraceCallStack::NamedParams namedParams;
582 namedParams["renderTarget"] << std::hex << renderTarget;
583 mCallStack.PushCall("PresentRenderTarget", "", namedParams);
587 * @brief Waits until the GPU is idle
589 void TestGraphicsController::WaitIdle()
591 mCallStack.PushCall("WaitIdle", "");
595 * @brief Lifecycle pause event
597 void TestGraphicsController::Pause()
599 mCallStack.PushCall("Pause", "");
603 * @brief Lifecycle resume event
605 void TestGraphicsController::Resume()
607 mCallStack.PushCall("Resume", "");
610 void TestGraphicsController::UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>& updateInfoList,
611 const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList)
613 TraceCallStack::NamedParams namedParams;
614 namedParams["updateInfoList"] << "[" << updateInfoList.size() << "]:";
615 namedParams["sourceList"] << "[" << sourceList.size() << "]:";
617 mCallStack.PushCall("UpdateTextures", "", namedParams);
619 // Call either TexImage2D or TexSubImage2D
620 for(unsigned int i = 0; i < updateInfoList.size(); ++i)
622 auto& updateInfo = updateInfoList[i];
623 auto& source = sourceList[i];
625 auto texture = static_cast<TestGraphicsTexture*>(updateInfo.dstTexture);
626 texture->Bind(0); // Use first texture unit during resource update
627 texture->Update(updateInfo, source);
631 bool TestGraphicsController::EnableDepthStencilBuffer(bool enableDepth, bool enableStencil)
633 TraceCallStack::NamedParams namedParams;
634 namedParams["enableDepth"] << (enableDepth ? "T" : "F");
635 namedParams["enableStencil"] << (enableStencil ? "T" : "F");
636 mCallStack.PushCall("EnableDepthStencilBuffer", "", namedParams);
640 void TestGraphicsController::RunGarbageCollector(size_t numberOfDiscardedRenderers)
642 TraceCallStack::NamedParams namedParams;
643 namedParams["numberOfDiscardedRenderers"] << numberOfDiscardedRenderers;
644 mCallStack.PushCall("RunGarbageCollector", "", namedParams);
647 void TestGraphicsController::DiscardUnusedResources()
649 mCallStack.PushCall("DiscardUnusedResources", "");
652 bool TestGraphicsController::IsDiscardQueueEmpty()
654 mCallStack.PushCall("IsDiscardQueueEmpty", "");
655 return isDiscardQueueEmptyResult;
659 * @brief Test if the graphics subsystem has resumed & should force a draw
661 * @return true if the graphics subsystem requires a re-draw
663 bool TestGraphicsController::IsDrawOnResumeRequired()
665 mCallStack.PushCall("IsDrawOnResumeRequired", "");
666 return isDrawOnResumeRequiredResult;
669 Graphics::UniquePtr<Graphics::Buffer> TestGraphicsController::CreateBuffer(const Graphics::BufferCreateInfo& createInfo, Graphics::UniquePtr<Graphics::Buffer>&& oldBuffer)
671 std::ostringstream oss;
672 oss << "bufferCreateInfo:" << createInfo;
673 mCallStack.PushCall("CreateBuffer", oss.str());
674 return Graphics::MakeUnique<TestGraphicsBuffer>(mCallStack, mGl, createInfo.size, createInfo.usage);
677 Graphics::UniquePtr<Graphics::CommandBuffer> TestGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr<Graphics::CommandBuffer>&& oldCommandBuffer)
679 std::ostringstream oss;
680 oss << "commandBufferCreateInfo:" << commandBufferCreateInfo;
681 mCallStack.PushCall("CreateCommandBuffer", oss.str());
682 return Graphics::MakeUnique<TestGraphicsCommandBuffer>(mCommandBufferCallStack, mGl);
685 Graphics::UniquePtr<Graphics::RenderPass> TestGraphicsController::CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr<Graphics::RenderPass>&& oldRenderPass)
687 mCallStack.PushCall("CreateRenderPass", "");
691 Graphics::UniquePtr<Graphics::Texture> TestGraphicsController::CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr<Graphics::Texture>&& oldTexture)
693 TraceCallStack::NamedParams namedParams;
694 namedParams["textureCreateInfo"] << textureCreateInfo;
695 mCallStack.PushCall("CreateTexture", namedParams.str(), namedParams);
697 return Graphics::MakeUnique<TestGraphicsTexture>(mGl, textureCreateInfo);
700 Graphics::UniquePtr<Graphics::Framebuffer> TestGraphicsController::CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr<Graphics::Framebuffer>&& oldFramebuffer)
702 mCallStack.PushCall("CreateFramebuffer", "");
706 Graphics::UniquePtr<Graphics::Pipeline> TestGraphicsController::CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr<Graphics::Pipeline>&& oldPipeline)
708 mCallStack.PushCall("CreatePipeline", "");
709 return std::make_unique<TestGraphicsPipeline>(mGl, pipelineCreateInfo);
712 Graphics::UniquePtr<Graphics::Program> TestGraphicsController::CreateProgram(const Graphics::ProgramCreateInfo& programCreateInfo, Graphics::UniquePtr<Graphics::Program>&& oldProgram)
714 mCallStack.PushCall("CreateProgram", "");
715 return Graphics::MakeUnique<TestGraphicsProgram>(mGl, programCreateInfo, mVertexFormats);
718 Graphics::UniquePtr<Graphics::Shader> TestGraphicsController::CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr<Graphics::Shader>&& oldShader)
720 mCallStack.PushCall("CreateShader", "");
721 return Graphics::MakeUnique<TestGraphicsShader>(mGl, shaderCreateInfo);
724 Graphics::UniquePtr<Graphics::Sampler> TestGraphicsController::CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr<Graphics::Sampler>&& oldSampler)
726 TraceCallStack::NamedParams namedParams;
727 namedParams["samplerCreateInfo"] << samplerCreateInfo;
728 mCallStack.PushCall("CreateSampler", namedParams.str(), namedParams);
730 return Graphics::MakeUnique<TestGraphicsSampler>(mGl, samplerCreateInfo);
733 Graphics::UniquePtr<Graphics::RenderTarget> TestGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr<Graphics::RenderTarget>&& oldRenderTarget)
735 mCallStack.PushCall("CreateRenderTarget", "");
739 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapBufferRange(const Graphics::MapBufferInfo& mapInfo)
741 mCallStack.PushCall("MapBufferRange", "");
743 auto buffer = static_cast<TestGraphicsBuffer*>(mapInfo.buffer);
744 buffer->memory.resize(mapInfo.offset + mapInfo.size); // For initial testing, allow writes past capacity
746 return std::make_unique<TestGraphicsMemory>(mCallStack, *buffer, mapInfo.offset, mapInfo.size);
749 Graphics::UniquePtr<Graphics::Memory> TestGraphicsController::MapTextureRange(const Graphics::MapTextureInfo& mapInfo)
751 mCallStack.PushCall("MapTextureRange", "");
755 void TestGraphicsController::UnmapMemory(Graphics::UniquePtr<Graphics::Memory> memory)
757 mCallStack.PushCall("UnmapMemory", "");
760 Graphics::MemoryRequirements TestGraphicsController::GetTextureMemoryRequirements(Graphics::Texture& texture) const
762 mCallStack.PushCall("GetTextureMemoryRequirements", "");
763 return Graphics::MemoryRequirements{};
766 Graphics::MemoryRequirements TestGraphicsController::GetBufferMemoryRequirements(Graphics::Buffer& buffer) const
768 mCallStack.PushCall("GetBufferMemoryRequirements", "");
769 return Graphics::MemoryRequirements{};
772 const Graphics::TextureProperties& TestGraphicsController::GetTextureProperties(const Graphics::Texture& texture)
774 static Graphics::TextureProperties textureProperties{};
775 mCallStack.PushCall("GetTextureProperties", "");
777 return textureProperties;
780 const Graphics::Reflection& TestGraphicsController::GetProgramReflection(const Graphics::Program& program)
782 mCallStack.PushCall("GetProgramReflection", "");
784 return static_cast<const TestGraphicsProgram*>(&program)->GetReflection();
787 bool TestGraphicsController::PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const
789 mCallStack.PushCall("PipelineEquals", "");
793 bool TestGraphicsController::GetProgramParameter(Graphics::Program& program, uint32_t parameterId, void* outData )
795 mCallStack.PushCall("GetProgramParameter", "");