void OpenGLBuffer::allocate()
{
- unsigned size = static_cast<const Buffer *>(this)->size;
+ size_t size = static_cast<const Buffer *>(this)->size;
if(ARB_buffer_storage)
{
}
}
-void OpenGLBuffer::sub_data(unsigned off, unsigned sz, const void *d)
+void OpenGLBuffer::sub_data(size_t off, size_t sz, const void *d)
{
if(ARB_direct_state_access)
glNamedBufferSubData(id, off, sz, d);
{
static Require _req(ARB_map_buffer_range);
- unsigned size = static_cast<const Buffer *>(this)->size;
+ size_t size = static_cast<const Buffer *>(this)->size;
if(ARB_direct_state_access)
return glMapNamedBufferRange(id, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT);
~OpenGLBuffer();
void allocate();
- void sub_data(unsigned, unsigned, const void *);
+ void sub_data(size_t, size_t, const void *);
void *map();
bool unmap();
::append<uint16_t>(data, i);
}
-unsigned Batch::get_index_size() const
+size_t Batch::get_index_size() const
{
return (index_type==UNSIGNED_INT ? sizeof(uint32_t) : sizeof(uint16_t));
}
-unsigned Batch::get_index(unsigned i) const
+unsigned Batch::get_index(size_t i) const
{
if(index_type==UNSIGNED_INT)
return *(uint32_t *)&data[i*sizeof(uint32_t)];
Batch &append(const Batch &);
private:
void append_index(unsigned);
- virtual unsigned get_data_size() const { return data.size(); }
+ virtual std::size_t get_data_size() const { return data.size(); }
virtual const void *get_data_pointer() const { return &data[0]; }
- virtual unsigned get_alignment() const { return get_index_size(); }
- unsigned get_index_size() const;
+ virtual std::size_t get_alignment() const { return get_index_size(); }
+ std::size_t get_index_size() const;
public:
- unsigned size() const { return data.size()/get_index_size(); }
+ std::size_t size() const { return data.size()/get_index_size(); }
- unsigned get_index(unsigned) const;
+ unsigned get_index(std::size_t) const;
};
} // namespace GL
namespace Msp {
namespace GL {
-void Buffer::storage(unsigned sz)
+void Buffer::storage(size_t sz)
{
if(size>0)
{
return sub_data(0, size, d);
}
-void Buffer::sub_data(unsigned off, unsigned sz, const void *d)
+void Buffer::sub_data(size_t off, size_t sz, const void *d)
{
if(size==0)
throw invalid_operation("Buffer::sub_data");
BufferBackend::sub_data(off, sz, d);
}
-void Buffer::require_size(unsigned req_sz) const
+void Buffer::require_size(size_t req_sz) const
{
if(size<req_sz)
throw buffer_too_small(format("buffer has %d bytes; %d required", size, req_sz));
friend BufferBackend;
private:
- unsigned size = 0;
+ std::size_t size = 0;
public:
/** Defines the storage size of the buffer. Must be called before data can
be uploaded. Storage cannot be changed once set. */
- void storage(unsigned);
+ void storage(std::size_t);
/** Uploads data into the buffer, completely replacing any previous
contents. Storage must be defined beforehand. The data must have size
/** Overwrites part of the buffer data with new data. Storage must be
defined beforehand. */
- void sub_data(unsigned, unsigned, const void *);
+ void sub_data(std::size_t, std::size_t, const void *);
- unsigned get_size() const { return size; }
+ std::size_t get_size() const { return size; }
- void require_size(unsigned) const;
+ void require_size(std::size_t) const;
using BufferBackend::map;
using BufferBackend::unmap;
}
}
-unsigned Bufferable::get_required_buffer_size() const
+size_t Bufferable::get_required_buffer_size() const
{
const Bufferable *last = this;
for(; last->next_in_buffer; last=last->next_in_buffer) ;
void Bufferable::update_offset()
{
- unsigned new_offset = 0;
+ size_t new_offset = 0;
if(prev_in_buffer)
new_offset = prev_in_buffer->offset+prev_in_buffer->get_data_size();
- unsigned align = get_alignment();
+ size_t align = get_alignment();
new_offset += align-1;
new_offset -= new_offset%align;
if(new_offset!=offset)
if(!buffer)
throw invalid_operation("Bufferable::upload_data");
- unsigned data_size = get_data_size();
+ size_t data_size = get_data_size();
if(location_dirty)
{
buffer->require_size(offset+data_size);
private:
Buffer *buffer = 0;
- unsigned offset = 0;
+ std::size_t offset = 0;
Bufferable *next_in_buffer = 0;
Bufferable *prev_in_buffer = 0;
mutable bool location_dirty = false;
/** Returns the total amount of storage required by this object and others
in the same chain, including any alignment between objects. */
- unsigned get_required_buffer_size() const;
+ std::size_t get_required_buffer_size() const;
/** Uploads new data into the buffer if necessary. */
void refresh() const { if(dirty) upload_data(0); }
const Buffer *get_buffer() const { return buffer; }
/** Returns the size of the data, in bytes. */
- virtual unsigned get_data_size() const = 0;
+ virtual std::size_t get_data_size() const = 0;
protected:
/** Returns a pointer to the start of data in client memory. */
/** Returns the alignment required for the data, in bytes. The offset is
guaranteed to be a multiple of this. */
- virtual unsigned get_alignment() const { return 1; }
+ virtual std::size_t get_alignment() const { return 1; }
/** Updates the offsets for the chain so that data from different objects
does not overlap. Should be called if either data size or alignment
public:
/** Returns the offset of the data from the beginning of the buffer. */
- unsigned get_offset() const { return offset; }
+ std::size_t get_offset() const { return offset; }
private:
/** Uploads data to the buffer. Receives pointer to mapped buffer memory as
SAMPLER_CUBE_ARRAY_SHADOW = 0x3C0304
};
-inline unsigned get_type_size(DataType t) { return t&0xFF; }
+inline std::size_t get_type_size(DataType t) { return t&0xFF; }
inline bool is_float(DataType t) { return t&0x200; }
inline bool is_matrix(DataType t) { return t&0xC000; }
inline bool is_vector(DataType t) { return !is_matrix(t) && (t&0x3000); }
}
}
-unsigned Mesh::get_n_vertices() const
+size_t Mesh::get_n_vertices() const
{
return vertices.size();
}
-char *Mesh::modify_vertex(unsigned i)
+char *Mesh::modify_vertex(size_t i)
{
if(vertices.get_format().empty())
throw invalid_operation("Mesh::modify_vertex");
const VertexArray &get_vertices() const { return vertices; }
const VertexSetup &get_vertex_setup() const { return vtx_setup; }
const Buffer *get_index_buffer() const { return ibuf; }
- unsigned get_n_vertices() const;
- char *modify_vertex(unsigned);
+ std::size_t get_n_vertices() const;
+ char *modify_vertex(std::size_t);
void add_batch(const Batch &b);
const std::vector<Batch> &get_batches() const { return batches; }
with the defined storage. Semantics depend on the type of texture. */
virtual void image(const Graphics::Image &, unsigned = 0) = 0;
- virtual std::uint64_t get_data_size() const { return 0; }
+ virtual std::size_t get_data_size() const { return 0; }
using TextureBackend::set_debug_name;
public:
virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
- virtual std::uint64_t get_data_size() const;
+ virtual std::size_t get_data_size() const;
virtual void unload() { }
};
public:
virtual Resource::AsyncLoader *load(IO::Seekable &, const Resources * = 0);
- virtual std::uint64_t get_data_size() const;
+ virtual std::size_t get_data_size() const;
using Texture2DBackend::unload;
};
unsigned get_samples() const { return samples; }
virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
- virtual std::uint64_t get_data_size() const;
+ virtual std::size_t get_data_size() const;
virtual void unload() { }
};
public:
virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
- virtual std::uint64_t get_data_size() const;
+ virtual std::size_t get_data_size() const;
virtual void unload() { }
};
Vector3 get_texel_direction(TextureCubeFace, unsigned, unsigned);
virtual AsyncLoader *load(IO::Seekable &, const Resources * = 0) { return 0; }
- virtual std::uint64_t get_data_size() const;
+ virtual std::size_t get_data_size() const;
virtual void unload() { }
};
data(info.data_size)
{ }
-unsigned UniformBlock::get_alignment() const
+size_t UniformBlock::get_alignment() const
{
return DeviceInfo::get_global().limits.uniform_buffer_alignment;
}
-void UniformBlock::store(const ReflectData::UniformInfo &info, unsigned array_size, const void *value)
+void UniformBlock::store(const ReflectData::UniformInfo &info, size_t array_size, const void *value)
{
- array_size = min(array_size, max(info.array_size, 1U));
+ array_size = min(array_size, max<size_t>(info.array_size, 1U));
char *store_ptr;
bool packed;
public:
UniformBlock(const ReflectData::UniformBlockInfo &);
- virtual unsigned get_data_size() const { return data.size(); }
+ virtual std::size_t get_data_size() const { return data.size(); }
virtual const void *get_data_pointer() const { return &data[0]; }
private:
- virtual unsigned get_alignment() const;
+ virtual std::size_t get_alignment() const;
public:
- void store(const ReflectData::UniformInfo &, unsigned, const void *);
+ void store(const ReflectData::UniformInfo &, std::size_t, const void *);
};
} // namespace GL
data.clear();
}
-void VertexArray::reserve(unsigned n)
+void VertexArray::reserve(size_t n)
{
if(format.empty())
throw invalid_operation("VertexArray::reserve");
return &*(data.end()-stride);
}
-char *VertexArray::modify(unsigned i)
+char *VertexArray::modify(size_t i)
{
if(format.empty())
throw invalid_operation("VertexArray::modify");
return &data[0]+i*stride;
}
-unsigned VertexArray::get_data_size() const
+size_t VertexArray::get_data_size() const
{
return data.size();
}
void clear();
/// Reserve space for vertices.
- void reserve(unsigned);
+ void reserve(std::size_t n);
/// Append a new vertex at the end of the array and return its location.
char *append();
/// Returns the location of a vertex for modification.
- char *modify(unsigned);
+ char *modify(std::size_t);
private:
- virtual unsigned get_data_size() const;
+ virtual std::size_t get_data_size() const;
virtual const void *get_data_pointer() const { return &data[0]; }
public:
- unsigned size() const { return data.size()/stride; }
+ std::size_t size() const { return data.size()/stride; }
const std::vector<char> &get_data() const { return data; }
- const char *operator[](unsigned i) const { return &data[0]+i*stride; }
+ const char *operator[](std::size_t i) const { return &data[0]+i*stride; }
};
} // namespace GL
/** Returns the amount of graphics memory used by this resource. The
returned value must not change while the resource is loaded. */
- virtual std::uint64_t get_data_size() const = 0;
+ virtual std::size_t get_data_size() const = 0;
virtual void unload() = 0;
};