From f704fc55afb1c7fa29939977096d51dc055b8366 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Wed, 30 Jan 2013 22:42:15 -0500 Subject: [PATCH] Flesh out the first few functions for our parallel stages. --- BPTCEncoder/src/ParallelStage.cpp | 35 ++++++++++++++++++++++++++----- BPTCEncoder/src/ParallelStage.h | 2 +- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/BPTCEncoder/src/ParallelStage.cpp b/BPTCEncoder/src/ParallelStage.cpp index 92ffda0..8a13b84 100644 --- a/BPTCEncoder/src/ParallelStage.cpp +++ b/BPTCEncoder/src/ParallelStage.cpp @@ -43,6 +43,9 @@ #include "ParallelStage.h" +#include +#include + /* const BC7ParallelStage stage; @@ -61,19 +64,41 @@ // This is the total number of blocks in this particular stage. uint32 m_NumBlocks; */ -ParallelStage::ParallelStage(BC7ParallelStage stage, const unsigned char *inbuf, unsigned char *outbuf, uint32 numBlocks) { - +ParallelStage::ParallelStage(BC7ParallelStage stage, const unsigned char *inbuf, unsigned char *outbuf, uint32 numBlocks) + : m_Stage(stage) + , m_InBuf(inbuf) + , m_OutBuf(outbuf) + , m_Blocks(new uint32[numBlocks]) + , m_TotalNumBlocks(numBlocks) + , m_NumBlocks(0) +{ + assert(numBlocks > 0); } -ParallelStage::ParallelStage(const ParallelStage &) { - +ParallelStage::ParallelStage(const ParallelStage &other) + : m_Stage(other.m_Stage) + , m_InBuf(other.m_InBuf) + , m_OutBuf(other.m_OutBuf) + , m_Blocks(new uint32[other.m_NumBlocks]) + , m_TotalNumBlocks(other.m_TotalNumBlocks) + , m_NumBlocks(other.m_NumBlocks) +{ + memcpy(m_Blocks, other.m_Blocks, m_NumBlocks * sizeof(m_Blocks[0])); } -ParallelStage &ParallelStage::operator=(const ParallelStage &) { +ParallelStage &ParallelStage::operator=(const ParallelStage &other) { + assert(m_Stage == other.m_Stage); + assert(m_InBuf == other.m_InBuf); + assert(m_OutBuf == other.m_OutBuf); + assert(m_TotalNumBlocks == other.m_TotalNumBlocks); + assert(m_NumBlocks == other.m_NumBlocks); + memcpy(m_Blocks, other.m_Blocks, m_NumBlocks * sizeof(m_Blocks[0])); } void ParallelStage::AddBlock(int blockNum) { + assert(m_NumBlocks < m_TotalNumBlocks); + m_Blocks[m_NumBlocks++] = blockNum; } \ No newline at end of file diff --git a/BPTCEncoder/src/ParallelStage.h b/BPTCEncoder/src/ParallelStage.h index 07beaef..44e049e 100644 --- a/BPTCEncoder/src/ParallelStage.h +++ b/BPTCEncoder/src/ParallelStage.h @@ -57,7 +57,7 @@ class ParallelStage { ParallelStage(const ParallelStage &); ParallelStage &operator=(const ParallelStage &); - const BC7ParallelStages stage; + const BC7ParallelStage m_Stage; void AddBlock(int blockNum);