• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef VK_BUFFER_VIEW_HPP_
16 #define VK_BUFFER_VIEW_HPP_
17 
18 #include "VkFormat.hpp"
19 #include "VkImageView.hpp"
20 #include "VkObject.hpp"
21 
22 namespace vk {
23 
24 class Buffer;
25 
26 class BufferView : public Object<BufferView, VkBufferView>
27 {
28 public:
29 	BufferView(const VkBufferViewCreateInfo *pCreateInfo, void *mem);
30 
ComputeRequiredAllocationSize(const VkBufferViewCreateInfo * pCreateInfo)31 	static size_t ComputeRequiredAllocationSize(const VkBufferViewCreateInfo *pCreateInfo)
32 	{
33 		return 0;
34 	}
35 
36 	void *getPointer() const;
getElementCount() const37 	uint32_t getElementCount() const { return static_cast<uint32_t>(range / Format(format).bytes()); }
getRangeInBytes() const38 	uint32_t getRangeInBytes() const { return static_cast<uint32_t>(range); }
getFormat() const39 	VkFormat getFormat() const { return format; }
40 
41 	const Identifier id;
42 
43 private:
44 	Buffer *buffer;
45 	VkFormat format;
46 	VkDeviceSize offset;
47 	VkDeviceSize range;
48 };
49 
Cast(VkBufferView object)50 static inline BufferView *Cast(VkBufferView object)
51 {
52 	return BufferView::Cast(object);
53 }
54 
55 }  // namespace vk
56 
57 #endif  // VK_BUFFER_VIEW_HPP_
58